@positivegrid/pg-mongoose-schema 27.8.3 → 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.
@@ -1,79 +1,97 @@
1
- 'use strict'
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
- type: {
8
- type: String,
9
- enum: ['tone_theme_query', 'tone_theme_ids'],
10
- required: true
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
- query: {
13
- type: Schema.Types.Mixed,
14
- default: null
15
- },
16
- ids: [{
17
- type: String
18
- }],
19
- limit: {
20
- type: Number,
21
- default: 12
22
- }
23
- }, { _id: false })
34
+ { _id: false }
35
+ );
24
36
 
25
- const SectionSchema = new Schema({
26
- section_type: {
27
- type: String,
28
- enum: ['banner', 'theme_list'],
29
- required: true
30
- },
31
- title: {
32
- type: String,
33
- default: null
34
- },
35
- order: {
36
- type: Number,
37
- required: true
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
+ },
38
56
  },
39
- data_source: {
40
- type: DataSourceSchema,
41
- required: true
42
- }
43
- }, { _id: false })
57
+ { _id: false }
58
+ );
44
59
 
45
- const HomeConfigSchema = new Schema({
46
- config_for: {
47
- type: String,
48
- required: true
49
- },
50
- locale: {
51
- type: String,
52
- default: 'en'
53
- },
54
- sections: [SectionSchema],
55
- is_active: {
56
- type: Boolean,
57
- default: false
58
- },
59
- created_on: {
60
- type: Date,
61
- default: Date.now
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
+ },
62
83
  },
63
- updated_on: {
64
- type: Date,
65
- default: Date.now
84
+ {
85
+ collection: "home_config",
66
86
  }
67
- }, {
68
- collection: 'home_config'
69
- })
87
+ );
70
88
 
71
89
  // 索引
72
90
  HomeConfigSchema.index({
73
91
  config_for: 1,
74
92
  locale: 1,
75
- is_active: 1
76
- })
93
+ is_active: 1,
94
+ });
77
95
 
78
- mongoose.model('HomeConfig', HomeConfigSchema)
79
- }
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",
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",