@dhyasama/totem-models 8.22.0 → 8.23.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.
Files changed (2) hide show
  1. package/lib/Deal.js +11 -4
  2. package/package.json +1 -1
package/lib/Deal.js CHANGED
@@ -200,11 +200,18 @@ module.exports = function(mongoose, config) {
200
200
 
201
201
  options = options || {};
202
202
 
203
- // { history: { $elemMatch: { timestamp: { $gte: ISODate("2019-01-03T20:45:14.406+0000") } } } }
204
-
205
203
  let terms = { 'customer': customerId };
206
- if (options.stage) { terms['stage'] = { $in: options.stage }; }
207
- if (options.since) { terms['history'] = { $elemMatch: { timestamp: { $gte: options.since } } }; }
204
+ if (options.stages) { terms['stage'] = { $in: options.stages }; }
205
+ if (options.added) {
206
+ if(options.added.lte && options.added.gte) terms['history.0.timestamp'] = { $lte: options.added.lte, $gte: options.added.gte };
207
+ else if(options.added.lte) terms['history.0.timestamp'] = { $lte: options.added.lte };
208
+ else if(options.added.gte) terms['history.0.timestamp'] = { $gte: options.added.gte };
209
+ }
210
+ if (options.updated) {
211
+ if(options.updated.lte && options.updated.gte) terms['history'] = { $elemMatch: { timestamp: { $lte: options.updated.lte, $gte: options.updated.gte } } };
212
+ else if(options.updated.lte) terms['history'] = { $elemMatch: { timestamp: { $lte: options.updated.lte } } };
213
+ else if(options.updated.gte) terms['history'] = { $elemMatch: { timestamp: { $gte: options.updated.gte } } };
214
+ };
208
215
 
209
216
  self
210
217
  .find(terms)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.22.0",
3
+ "version": "8.23.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",