@positivegrid/pg-mongoose-schema 27.1.1 → 27.1.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.
Files changed (2) hide show
  1. package/models/preset.js +11 -7
  2. package/package.json +1 -1
package/models/preset.js CHANGED
@@ -751,15 +751,19 @@ module.exports = function (mongoose) {
751
751
  },
752
752
  getPresetLikeList: function (query, sort, req, cb) {
753
753
  const pageParams = parsePageParams(req.query)
754
- const defaultPresetCondition = {
755
- 'preset.status': { '$eq': 0 }
756
- }
757
- if (_.has(query, 'no_dspid')) {
758
- defaultPresetCondition['preset.preset_meta.dspId'] = { '$nin': String(query.no_dspid).split(',') }
759
- }
754
+ const defaultPresetCondition = {
755
+ 'preset.status': { '$eq': 0 }
756
+ }
757
+ let filterQuery = {}
758
+ if (_.has(query, 'no_dspid')) {
759
+ defaultPresetCondition['preset.preset_meta.dspId'] = { '$nin': String(query.no_dspid).split(',') }
760
+ filterQuery = _.omit(query, ['no_dspid'])
761
+ } else {
762
+ filterQuery = _.clone(query)
763
+ }
760
764
 
761
765
  const aggregateQuery = [{
762
- '$match': _.assign({}, _queryCompatibilityHandler(query), { user_id: mongoose.Types.ObjectId(query['user_id']) })
766
+ '$match': _.assign({}, _queryCompatibilityHandler(filterQuery), { user_id: mongoose.Types.ObjectId(filterQuery['user_id']) })
763
767
  }, {
764
768
  '$lookup': {
765
769
  'from': 'jamup_preset',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positivegrid/pg-mongoose-schema",
3
- "version": "27.1.1",
3
+ "version": "27.1.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",