@positivegrid/pg-mongoose-schema 27.3.2 → 27.3.4

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.
@@ -143,22 +143,28 @@ module.exports = function (mongoose) {
143
143
  const tmpDeviceList = device_list.split(',')
144
144
  let deviceList = []
145
145
  const allTypeSet = new Set()
146
+ const uniqueProductLineSet = new Set()
146
147
  tmpDeviceList.forEach(deviceItem => {
147
148
  const optionItem = deviceItem.split('_')
149
+ uniqueProductLineSet.add(optionItem[0])
148
150
  if (optionItem.length === 2 && optionItem[1] === 'all') {
149
151
  allTypeSet.add(optionItem[0])
150
152
  } else {
151
153
  deviceList.push(deviceItem)
152
154
  }
153
155
  })
154
- let allTypeRegex = []
155
156
  if (allTypeSet.size > 0) {
156
157
  allTypeSet.forEach(item => {
157
- allTypeRegex.push(/^' + item + '_/)
158
+ deviceList.push(new RegExp(`^${item}_`))
159
+ })
160
+ }
161
+ if (uniqueProductLineSet.size > 0) {
162
+ uniqueProductLineSet.forEach(item => {
163
+ deviceList.push(`${item}_all`)
158
164
  })
159
165
  }
160
166
  defaultQuery['$and'].push({
161
- 'device_list': { $in: deviceList.concat(allTypeRegex) }
167
+ 'device_list': { $in: deviceList }
162
168
  })
163
169
  } else {
164
170
  defaultQuery['$and'].push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positivegrid/pg-mongoose-schema",
3
- "version": "27.3.2",
3
+ "version": "27.3.4",
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",