@positivegrid/pg-mongoose-schema 26.2.0 → 26.3.0

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/payment.js CHANGED
@@ -604,6 +604,15 @@ module.exports = function (mongoose) {
604
604
  }
605
605
  })
606
606
  },
607
+ hasLicensePromise: async function (userID, productID) {
608
+ const hasProduct = await this.findOne({
609
+ user_id: userID,
610
+ product_id: productID,
611
+ status: 1,
612
+ '$or': [{ 'due_date': null }, { 'due_date': { $gt: new Date() } }]
613
+ }).exec()
614
+ return (hasProduct)
615
+ },
607
616
  getLicenseByRedeem: function (redeem, cb) {
608
617
  this.find({ from_redeem: redeem }).sort({ created_on: -1 }).exec(cb)
609
618
  },
package/models/preset.js CHANGED
@@ -366,6 +366,11 @@ module.exports = function (mongoose) {
366
366
  text: {
367
367
  path: 'name',
368
368
  query: req.query.keyword,
369
+ fuzzy: {
370
+ maxEdits: 1,
371
+ prefixLength: 1,
372
+ maxExpansions: 30
373
+ },
369
374
  score: {
370
375
  boost: {
371
376
  value: 3
@@ -375,7 +380,12 @@ module.exports = function (mongoose) {
375
380
  }, {
376
381
  text: {
377
382
  path: ['description', 'category'],
378
- query: req.query.keyword
383
+ query: req.query.keyword,
384
+ fuzzy: {
385
+ maxEdits: 2,
386
+ prefixLength: 0,
387
+ maxExpansions: 50
388
+ }
379
389
  }
380
390
  })
381
391
 
package/models/redeem.js CHANGED
@@ -17,7 +17,7 @@ module.exports = function (mongoose) {
17
17
  created_on: { type: Date, default: Date.now },
18
18
  updated_on: { type: Date, default: Date.now }
19
19
  }, { collection: 'pg_redeem_code' })
20
- RedeemCodeSchema.index({ code: 1 }, { unique: true })
20
+ RedeemCodeSchema.index({ code: 1, status: 1 }, { unique: true })
21
21
  RedeemCodeSchema.index({ code: 1, product_id: 1, status: 1 })
22
22
  RedeemCodeSchema.index({ code: 1, bundle_id: 1, status: 1 })
23
23
  RedeemCodeSchema.index({ tracker: 1 })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positivegrid/pg-mongoose-schema",
3
- "version": "26.2.0",
3
+ "version": "26.3.0",
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",