@positivegrid/pg-mongoose-schema 27.8.4 → 27.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/models/homeConfig.js +82 -71
- package/package.json +1 -1
package/models/homeConfig.js
CHANGED
|
@@ -1,86 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = function (mongoose) {
|
|
4
|
-
const Schema = mongoose.Schema
|
|
4
|
+
const Schema = mongoose.Schema;
|
|
5
5
|
|
|
6
|
-
const DataSourceSchema = new Schema(
|
|
7
|
-
|
|
8
|
-
type:
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const DataSourceSchema = new Schema(
|
|
7
|
+
{
|
|
8
|
+
type: {
|
|
9
|
+
type: String,
|
|
10
|
+
enum: ["tone_theme_query", "tone_theme_ids", "tone_theme_id"],
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
// 單一 theme ID(當 type = 'tone_theme_id')
|
|
14
|
+
tone_theme_id: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: null,
|
|
17
|
+
},
|
|
18
|
+
// 動態查詢(當 type = 'tone_theme_query')
|
|
19
|
+
query: {
|
|
20
|
+
type: Schema.Types.Mixed,
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
23
|
+
// 多個 theme IDs(當 type = 'tone_theme_ids')
|
|
24
|
+
ids: [
|
|
25
|
+
{
|
|
26
|
+
type: String,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
limit: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 12,
|
|
32
|
+
},
|
|
11
33
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type: String,
|
|
15
|
-
default: null
|
|
16
|
-
},
|
|
17
|
-
// 動態查詢(當 type = 'tone_theme_query')
|
|
18
|
-
query: {
|
|
19
|
-
type: Schema.Types.Mixed,
|
|
20
|
-
default: null
|
|
21
|
-
},
|
|
22
|
-
// 多個 theme IDs(當 type = 'tone_theme_ids')
|
|
23
|
-
ids: [{
|
|
24
|
-
type: String
|
|
25
|
-
}],
|
|
26
|
-
limit: {
|
|
27
|
-
type: Number,
|
|
28
|
-
default: 12
|
|
29
|
-
}
|
|
30
|
-
}, { _id: false })
|
|
34
|
+
{ _id: false }
|
|
35
|
+
);
|
|
31
36
|
|
|
32
|
-
const SectionSchema = new Schema(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
const SectionSchema = new Schema(
|
|
38
|
+
{
|
|
39
|
+
section_type: {
|
|
40
|
+
type: String,
|
|
41
|
+
enum: ["tone_theme_banner", "tone_theme_list", "tone_theme_lists"],
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
title: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
order: {
|
|
49
|
+
type: Number,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
data_source: {
|
|
53
|
+
type: DataSourceSchema,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
45
56
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
required: true
|
|
49
|
-
}
|
|
50
|
-
}, { _id: false })
|
|
57
|
+
{ _id: false }
|
|
58
|
+
);
|
|
51
59
|
|
|
52
|
-
const HomeConfigSchema = new Schema(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const HomeConfigSchema = new Schema(
|
|
61
|
+
{
|
|
62
|
+
config_for: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
locale: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: "en",
|
|
69
|
+
},
|
|
70
|
+
sections: [SectionSchema],
|
|
71
|
+
is_active: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false,
|
|
74
|
+
},
|
|
75
|
+
created_on: {
|
|
76
|
+
type: Date,
|
|
77
|
+
default: Date.now,
|
|
78
|
+
},
|
|
79
|
+
updated_on: {
|
|
80
|
+
type: Date,
|
|
81
|
+
default: Date.now,
|
|
82
|
+
},
|
|
69
83
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
default: Date.now
|
|
84
|
+
{
|
|
85
|
+
collection: "home_config",
|
|
73
86
|
}
|
|
74
|
-
|
|
75
|
-
collection: 'home_config'
|
|
76
|
-
})
|
|
87
|
+
);
|
|
77
88
|
|
|
78
89
|
// 索引
|
|
79
90
|
HomeConfigSchema.index({
|
|
80
91
|
config_for: 1,
|
|
81
92
|
locale: 1,
|
|
82
|
-
is_active: 1
|
|
83
|
-
})
|
|
93
|
+
is_active: 1,
|
|
94
|
+
});
|
|
84
95
|
|
|
85
|
-
mongoose.model(
|
|
86
|
-
}
|
|
96
|
+
mongoose.model("HomeConfig", HomeConfigSchema);
|
|
97
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positivegrid/pg-mongoose-schema",
|
|
3
|
-
"version": "27.8.
|
|
3
|
+
"version": "27.8.5",
|
|
4
4
|
"description": "Positive Grid mongoose schema",
|
|
5
5
|
"author": "Ferrari Lee <shiyung@positivegrid.com>",
|
|
6
6
|
"homepage": "https://git.positivegrid.com:8443/backend/pg-mongoose-schema",
|