@positivegrid/pg-mongoose-schema 27.2.2-beta.0 → 27.2.2-beta.2
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/promotion.js +21 -1
- package/package.json +1 -1
package/models/promotion.js
CHANGED
|
@@ -140,8 +140,28 @@ module.exports = function (mongoose) {
|
|
|
140
140
|
|
|
141
141
|
if (!_.isUndefined(device_list) && _.isString(device_list)) {
|
|
142
142
|
const deviceList = device_list.split(',')
|
|
143
|
+
|
|
144
|
+
// all value must follow the same format
|
|
145
|
+
// e.g., spark_all, spark_gen2, spark_40
|
|
146
|
+
const singletoneProductName = new Set()
|
|
147
|
+
deviceList.forEach(deviceItem => {
|
|
148
|
+
const tmp = deviceItem.split('_')
|
|
149
|
+
if (tmp.length === 2) {
|
|
150
|
+
singletoneProductName.add(`${tmp[0]}_all`)
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
const allSelectedProduct = []
|
|
154
|
+
if (singletoneProductName.size > 0) {
|
|
155
|
+
allSelectedProduct.push({
|
|
156
|
+
'device_list': {
|
|
157
|
+
'$in': Array.from(singletoneProductName)
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
}
|
|
143
161
|
defaultQuery['$and'].push({
|
|
144
|
-
'
|
|
162
|
+
'$or': [{
|
|
163
|
+
'device_list': { $in: deviceList }
|
|
164
|
+
}].concat(allSelectedProduct)
|
|
145
165
|
})
|
|
146
166
|
}
|
|
147
167
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positivegrid/pg-mongoose-schema",
|
|
3
|
-
"version": "27.2.2-beta.
|
|
3
|
+
"version": "27.2.2-beta.2",
|
|
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",
|