@dhyasama/totem-models 9.125.0 → 9.126.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 +24 -2
  2. package/package.json +1 -1
package/lib/Deal.js CHANGED
@@ -61,8 +61,9 @@ module.exports = function(mongoose, config) {
61
61
  latestMessage: { type: Schema.ObjectId, ref: 'Message', required: false },
62
62
 
63
63
  applications: [{
64
- name: { type: String, trim: true },
65
- appliedOn: { type: Date, default: Date.now }
64
+ application: { type: String, trim: true },
65
+ appliedOn: { type: Date, default: Date.now },
66
+ appliedBy: { type: String, trim: true }
66
67
  }]
67
68
 
68
69
  });
@@ -249,6 +250,27 @@ module.exports = function(mongoose, config) {
249
250
 
250
251
  };
251
252
 
253
+ Deal.statics.getByApplication = function (application, options, cb) {
254
+
255
+ let self = this;
256
+
257
+ if (!cb) { throw new Error('cb is required'); }
258
+ if (!personId) { return cb(new Error('personId is required'), null); }
259
+ if (!mongoose.Types.ObjectId.isValid(personId)) { return cb(new Error('personId is not a valid ObjectId'), null); }
260
+ if (!options) { return cb(new Error('options is required'), null); }
261
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
262
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
263
+
264
+ let query = self.find({
265
+ 'applications.application': application,
266
+ 'customer': options.CUSTOMER_ID
267
+ });
268
+
269
+ query.populate('organization', 'name description');
270
+ query.exec(cb);
271
+
272
+ };
273
+
252
274
  // Get a deal for a org, belonging to current customer
253
275
  Deal.statics.getForOrg = function (orgId, options, cb) {
254
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "9.125.0",
3
+ "version": "9.126.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",