@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.
@@ -1,86 +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', 'tone_theme_id'],
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
- // 單一 theme ID(當 type = 'tone_theme_id')
13
- tone_theme_id: {
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
- section_type: {
34
- type: String,
35
- enum: ['banner', 'theme_list'],
36
- required: true
37
- },
38
- title: {
39
- type: String,
40
- default: null
41
- },
42
- order: {
43
- type: Number,
44
- 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
+ },
45
56
  },
46
- data_source: {
47
- type: DataSourceSchema,
48
- required: true
49
- }
50
- }, { _id: false })
57
+ { _id: false }
58
+ );
51
59
 
52
- const HomeConfigSchema = new Schema({
53
- config_for: {
54
- type: String,
55
- required: true
56
- },
57
- locale: {
58
- type: String,
59
- default: 'en'
60
- },
61
- sections: [SectionSchema],
62
- is_active: {
63
- type: Boolean,
64
- default: false
65
- },
66
- created_on: {
67
- type: Date,
68
- 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
+ },
69
83
  },
70
- updated_on: {
71
- type: Date,
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('HomeConfig', HomeConfigSchema)
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.4",
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",