@dhyasama/totem-models 6.20.2 → 6.21.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 +17 -2
- package/package.json +1 -1
package/lib/Deal.js
CHANGED
|
@@ -7,7 +7,8 @@ module.exports = function(mongoose, config) {
|
|
|
7
7
|
Schema = mongoose.Schema,
|
|
8
8
|
postFind = require('mongoose-post-find'),
|
|
9
9
|
async = require('async'),
|
|
10
|
-
_ = require('underscore')
|
|
10
|
+
_ = require('underscore'),
|
|
11
|
+
moment = require('moment');
|
|
11
12
|
|
|
12
13
|
var Deal = new Schema({
|
|
13
14
|
|
|
@@ -190,7 +191,7 @@ module.exports = function(mongoose, config) {
|
|
|
190
191
|
|
|
191
192
|
});
|
|
192
193
|
};
|
|
193
|
-
|
|
194
|
+
|
|
194
195
|
// Get all deals belonging to a customer
|
|
195
196
|
Deal.statics.getForCustomer = function (customerId, options, cb) {
|
|
196
197
|
|
|
@@ -244,6 +245,20 @@ module.exports = function(mongoose, config) {
|
|
|
244
245
|
|
|
245
246
|
};
|
|
246
247
|
|
|
248
|
+
Deal.statics.getByReferrer = function (personId, cb) {
|
|
249
|
+
|
|
250
|
+
var self = this;
|
|
251
|
+
|
|
252
|
+
self
|
|
253
|
+
.find({
|
|
254
|
+
'referrer.person': personId,
|
|
255
|
+
'customer': config.CUSTOMER_ID
|
|
256
|
+
})
|
|
257
|
+
.populate('organization', 'name logoUrl website websiteAliases')
|
|
258
|
+
.exec(cb);
|
|
259
|
+
|
|
260
|
+
};
|
|
261
|
+
|
|
247
262
|
// Get a deal for a org, belonging to current customer
|
|
248
263
|
Deal.statics.getForOrg = function (orgId, cb) {
|
|
249
264
|
|