@dhyasama/totem-models 8.22.0 → 8.23.1
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/lib/Deal.js +11 -4
- package/package.json +1 -1
- package/test/Deal.js +0 -15
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.
|
|
207
|
-
if (options.
|
|
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
package/test/Deal.js
CHANGED
|
@@ -237,21 +237,6 @@ describe('Deal', function() {
|
|
|
237
237
|
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
it('gets new deals for a customer', function(done) {
|
|
241
|
-
|
|
242
|
-
Deal.getForCustomer(customer._id, { since: timestamps[0] }, function(err, result) {
|
|
243
|
-
|
|
244
|
-
should.not.exist(err);
|
|
245
|
-
should.exist(result);
|
|
246
|
-
|
|
247
|
-
result.length.should.be.greaterThan(0);
|
|
248
|
-
|
|
249
|
-
return done();
|
|
250
|
-
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
|
|
255
240
|
it('deletes a deal', function(done) {
|
|
256
241
|
Deal.delete(dealId, { CUSTOMER_ID: customer._id }, function(err, result) {
|
|
257
242
|
should.not.exist(err);
|