@dhyasama/totem-models 8.23.0 → 8.24.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/lib/Deal.js CHANGED
@@ -188,10 +188,6 @@ module.exports = function(mongoose, config) {
188
188
  // Get all deals belonging to a customer
189
189
  Deal.statics.getForCustomer = function (customerId, options, cb) {
190
190
 
191
- // todo - fix deep population
192
- // not sure why chained deepPopulate isn't working (it throws an error)
193
- // it works to deepPopulate each result instance in parallel
194
-
195
191
  let self = this;
196
192
 
197
193
  if (!cb) { throw new Error('cb is required'); }
@@ -213,13 +209,8 @@ module.exports = function(mongoose, config) {
213
209
  else if(options.updated.gte) terms['history'] = { $elemMatch: { timestamp: { $gte: options.updated.gte } } };
214
210
  };
215
211
 
216
- self
217
- .find(terms)
218
- .populate({ path: 'documents', match: { customer: customerId } })
219
- .populate({ path: 'messages', match: { customer: customerId } })
220
- .populate('organization', 'name description logoUrl website websiteAliases chairs contact')
221
- .populate('referrer.person', 'name avatarUrl title')
222
- .exec(cb);
212
+ let query = self.find(terms);
213
+ query.exec(cb);
223
214
 
224
215
  };
225
216
 
package/lib/Message.js CHANGED
@@ -75,7 +75,7 @@ module.exports = function(mongoose, config) {
75
75
 
76
76
  };
77
77
 
78
- Message.statics.deleteDocument = function(docId, cb) {
78
+ Message.statics.deleteDocument = function(docId, customerId, cb) {
79
79
 
80
80
  // Delete the doc itself along with any references
81
81
 
@@ -88,7 +88,7 @@ module.exports = function(mongoose, config) {
88
88
  };
89
89
 
90
90
  async.series([
91
- Document.delete.bind(Document, docId),
91
+ Document.delete.bind(Document, { CUSTOMER_ID: customerId }, docId),
92
92
  removeReferences
93
93
  ], function(err, results) {
94
94
  return cb(err, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.23.0",
3
+ "version": "8.24.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
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);