@dhyasama/totem-models 6.20.0 → 6.20.2
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 +28 -2
- package/package.json +1 -1
package/lib/Deal.js
CHANGED
|
@@ -162,9 +162,35 @@ module.exports = function(mongoose, config) {
|
|
|
162
162
|
Deal.statics.getByIds = function (ids, cb) {
|
|
163
163
|
this
|
|
164
164
|
.find({customer: config.CUSTOMER_ID, '_id': { $in : ids } })
|
|
165
|
-
.
|
|
166
|
-
|
|
165
|
+
.populate('organization', 'name description logoUrl website websiteAliases chairs')
|
|
166
|
+
.populate('messages')
|
|
167
|
+
.populate('source.person', 'name avatarUrl title')
|
|
168
|
+
.populate('referrer.person', 'name avatarUrl title')
|
|
169
|
+
.populate({
|
|
170
|
+
path: 'documents',
|
|
171
|
+
match: { customer: config.CUSTOMER_ID }
|
|
172
|
+
})
|
|
173
|
+
.exec(function(err, deals) {
|
|
167
174
|
|
|
175
|
+
if (err) return cb(err, null);
|
|
176
|
+
else if (!deals || deals.length == 0) return cb(null, []);
|
|
177
|
+
|
|
178
|
+
var calls = [];
|
|
179
|
+
|
|
180
|
+
_.each(deals, function(deal) {
|
|
181
|
+
var func = function(callback) {
|
|
182
|
+
deal.deepPopulate('organization.chairs.first', {
|
|
183
|
+
populate: { 'organization.chairs.first': { select: 'name avatarUrl title doNotDisplay' } }
|
|
184
|
+
}, callback);
|
|
185
|
+
};
|
|
186
|
+
calls.push(func);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
async.parallel(calls, cb);
|
|
190
|
+
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
168
194
|
// Get all deals belonging to a customer
|
|
169
195
|
Deal.statics.getForCustomer = function (customerId, options, cb) {
|
|
170
196
|
|