@positivegrid/pg-mongoose-schema 27.3.1 → 27.3.3

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