@dhyasama/totem-models 12.0.0 → 12.1.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
@@ -843,9 +843,6 @@ module.exports = function(mongoose, config) {
843
843
  Deal.set('autoIndex', false);
844
844
  Deal.on('index', function(err) { console.log('error building deal indexes: ' + err); });
845
845
 
846
- const deepPopulate = require('mongoose-deep-populate')(mongoose);
847
- Deal.plugin(deepPopulate);
848
-
849
846
  mongoose.model('Deal', Deal);
850
847
 
851
848
  };
@@ -399,9 +399,6 @@ module.exports = function(mongoose, config) {
399
399
  Interaction.set('autoIndex', false);
400
400
  Interaction.on('index', function(err) { console.log('error building interaction indexes: ' + err); });
401
401
 
402
- var deepPopulate = require('mongoose-deep-populate')(mongoose);
403
- Interaction.plugin(deepPopulate);
404
-
405
402
  mongoose.model('Interaction', Interaction);
406
403
 
407
404
  };
@@ -375,23 +375,17 @@ module.exports = function(mongoose, config) {
375
375
  }
376
376
 
377
377
  query.populate('transactions.fund');
378
- query.populate('people');
378
+ query.populate({
379
+ path: 'people',
380
+ populate: { path: 'sources.person', select: 'name avatarUrl title' }
381
+ });
379
382
  query.populate({
380
383
  path: 'notes',
381
- match: { customer: options.CUSTOMER_ID }
384
+ match: { customer: options.CUSTOMER_ID },
385
+ populate: { path: 'createdBy', select: 'name avatarUrl' }
382
386
  });
383
387
  query.populate('documents');
384
388
 
385
- query.deepPopulate([
386
- 'people.sources.person',
387
- 'notes.createdBy'
388
- ], {
389
- populate: {
390
- 'people.sources.person': { select: 'name avatarUrl title' },
391
- 'notes.createdBy': { select: 'name avatarUrl' }
392
- }
393
- });
394
-
395
389
  query.exec().then(function(lp) {
396
390
  if (!lp) { return cb(null, null); }
397
391
 
@@ -526,14 +520,8 @@ module.exports = function(mongoose, config) {
526
520
  query.populate({
527
521
  path: 'notes',
528
522
  match: { customer: options.CUSTOMER_ID },
529
- options: { sort: { createdOn: -1 } }
530
- });
531
- query.deepPopulate([
532
- 'notes.createdBy'
533
- ], {
534
- populate: {
535
- 'notes.createdBy': { select: 'name avatarUrl title' }
536
- }
523
+ options: { sort: { createdOn: -1 } },
524
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
537
525
  });
538
526
 
539
527
  query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
@@ -553,13 +541,10 @@ module.exports = function(mongoose, config) {
553
541
 
554
542
  let query = self.findById(lpid);
555
543
 
556
- query.populate('people', 'name avatarUrl title doNotDisplay sources');
557
- query.deepPopulate([
558
- 'people.sources.person'
559
- ], {
560
- populate: {
561
- 'people.sources.person': { select: 'name avatarUrl title doNotDisplay' }
562
- }
544
+ query.populate({
545
+ path: 'people',
546
+ select: 'name avatarUrl title doNotDisplay sources',
547
+ populate: { path: 'sources.person', select: 'name avatarUrl title doNotDisplay' }
563
548
  });
564
549
 
565
550
  query.exec().then(function(lp) {if (!lp) { return cb(null, null); }
@@ -888,9 +873,6 @@ module.exports = function(mongoose, config) {
888
873
 
889
874
  LimitedPartner.set('toJSON', { virtuals: true });
890
875
 
891
- let deepPopulate = require('mongoose-deep-populate')(mongoose);
892
- LimitedPartner.plugin(deepPopulate);
893
-
894
876
  mongoose.model('LimitedPartner', LimitedPartner);
895
877
 
896
878
  };
package/lib/Message.js CHANGED
@@ -96,14 +96,8 @@ module.exports = function(mongoose, config) {
96
96
  query.where({'attendees.external': { $in : personIds }});
97
97
  query.populate({
98
98
  path: 'documents',
99
- match: { customer: options.CUSTOMER_ID }
100
- });
101
- query.deepPopulate([
102
- 'documents.createdBy'
103
- ], {
104
- populate: {
105
- 'documents.createdBy': { select: 'name avatarUrl title' }
106
- }
99
+ match: { customer: options.CUSTOMER_ID },
100
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
107
101
  });
108
102
 
109
103
  query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
@@ -181,14 +175,8 @@ module.exports = function(mongoose, config) {
181
175
  query.populate('recipients.external', 'name title avatarUrl doNotDisplay');
182
176
  query.populate({
183
177
  path: 'documents',
184
- match: { customer: options.CUSTOMER_ID }
185
- });
186
- query.deepPopulate([
187
- 'documents.createdBy'
188
- ], {
189
- populate: {
190
- 'documents.createdBy': { select: 'name avatarUrl title' }
191
- }
178
+ match: { customer: options.CUSTOMER_ID },
179
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
192
180
  });
193
181
 
194
182
  query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
@@ -312,14 +300,8 @@ module.exports = function(mongoose, config) {
312
300
  query.populate('recipients.external', 'name title avatarUrl doNotDisplay');
313
301
  query.populate({
314
302
  path: 'documents',
315
- match: { customer: options.CUSTOMER_ID }
316
- });
317
- query.deepPopulate([
318
- 'documents.createdBy'
319
- ], {
320
- populate: {
321
- 'documents.createdBy': { select: 'name avatarUrl title' }
322
- }
303
+ match: { customer: options.CUSTOMER_ID },
304
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
323
305
  });
324
306
 
325
307
  query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
@@ -418,9 +400,6 @@ module.exports = function(mongoose, config) {
418
400
  Message.set('autoIndex', false);
419
401
  Message.set('toJSON', { virtuals: true });
420
402
 
421
- let deepPopulate = require('mongoose-deep-populate')(mongoose);
422
- Message.plugin(deepPopulate);
423
-
424
403
  mongoose.model('Message', Message);
425
404
 
426
405
  };
@@ -1168,24 +1168,20 @@ module.exports = function(mongoose, config) {
1168
1168
 
1169
1169
  self
1170
1170
  .find({ '_id': { $in : ids }})
1171
- .populate('people.person', 'name avatarUrl title doNotDisplay calendarEventSummaries sources')
1171
+ .populate({
1172
+ path: 'people.person',
1173
+ select: 'name avatarUrl title doNotDisplay calendarEventSummaries sources',
1174
+ populate: [
1175
+ { path: 'sources.person', select: 'name avatarUrl title doNotDisplay' },
1176
+ { path: 'calendarEventSummaries.attendees.internal', select: 'name avatarUrl title doNotDisplay' },
1177
+ { path: 'calendarEventSummaries.attendees.external', select: 'name avatarUrl title doNotDisplay' },
1178
+ { path: 'calendarEventSummaries.notes', populate: { path: 'createdBy', select: 'name avatarUrl title doNotDisplay' } }
1179
+ ]
1180
+ })
1172
1181
  .populate('related', 'name logoUrl')
1173
1182
  .populate('chairs.first', 'name avatarUrl title')
1174
1183
  .populate('chairs.second', 'name avatarUrl title')
1175
1184
  .populate('funds', 'name hexColorCode abbreviation')
1176
- .deepPopulate([
1177
- 'people.person.sources.person',
1178
- 'people.person.calendarEventSummaries.attendees.internal',
1179
- 'people.person.calendarEventSummaries.attendees.external',
1180
- 'people.person.calendarEventSummaries.notes.createdBy'
1181
- ], {
1182
- populate: {
1183
- 'people.person.sources.person': { select: 'name avatarUrl title doNotDisplay' },
1184
- 'people.person.calendarEventSummaries.attendees.internal': { select: 'name avatarUrl title doNotDisplay' },
1185
- 'people.person.calendarEventSummaries.attendees.external': { select: 'name avatarUrl title doNotDisplay' },
1186
- 'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title doNotDisplay' }
1187
- }
1188
- })
1189
1185
  .exec().then(function(orgs) {
1190
1186
  if (!orgs) { return cb(null, []); }
1191
1187
 
@@ -1502,27 +1498,16 @@ module.exports = function(mongoose, config) {
1502
1498
  query.populate('operating.acquired.private.by', 'name logoUrl');
1503
1499
  query.populate('operating.merged.public.with', 'name logoUrl');
1504
1500
  query.populate('operating.merged.private.with', 'name logoUrl');
1501
+ dealPopulateOptions.populate = [
1502
+ { path: 'source.person' },
1503
+ { path: 'history.account' }
1504
+ ];
1505
1505
  query.populate(dealPopulateOptions);
1506
+ query.populate('documents');
1506
1507
 
1507
1508
  if (options.role !== 'none') {
1509
+ lpPopulateOptions.populate = { path: 'transactions.fund', select: 'shortName' };
1508
1510
  query.populate(lpPopulateOptions);
1509
- query.deepPopulate([
1510
- 'deals.sources.person',
1511
- 'documents',
1512
- 'history.account',
1513
- 'lps.fundsInvested.fund'
1514
- ], {
1515
- populate: {
1516
- 'lps.fundsInvested.fund': { select: 'shortName' }
1517
- }
1518
- })
1519
- }
1520
- else {
1521
- query.deepPopulate([
1522
- 'deals.sources.person',
1523
- 'documents',
1524
- 'history.account'
1525
- ]);
1526
1511
  }
1527
1512
 
1528
1513
  query.exec().then(function(result) {if (options.isWorkerProcess) { return cb(null, result); }
@@ -1783,20 +1768,19 @@ module.exports = function(mongoose, config) {
1783
1768
  let query = self.findById(orgid);
1784
1769
 
1785
1770
  query.select('notes people.person');
1786
- query.populate('people.person', 'name avatarUrl title calendarEventSummaries');
1787
1771
  query.populate({
1788
- path: 'notes',
1789
- match: { customer: options.CUSTOMER_ID }
1790
- });
1791
- query.deepPopulate([
1792
- 'notes.createdBy',
1793
- 'people.person.calendarEventSummaries.notes.createdBy'
1794
- ], {
1772
+ path: 'people.person',
1773
+ select: 'name avatarUrl title calendarEventSummaries',
1795
1774
  populate: {
1796
- 'notes.createdBy': { select: 'name avatarUrl title' },
1797
- 'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title' }
1775
+ path: 'calendarEventSummaries.notes',
1776
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
1798
1777
  }
1799
1778
  });
1779
+ query.populate({
1780
+ path: 'notes',
1781
+ match: { customer: options.CUSTOMER_ID },
1782
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
1783
+ });
1800
1784
  query.sort({'createdOn':-1});
1801
1785
 
1802
1786
  query.exec().then(function(org) {
@@ -1823,13 +1807,10 @@ module.exports = function(mongoose, config) {
1823
1807
 
1824
1808
  let query = self.findById(id);
1825
1809
  query.select('people');
1826
- query.populate('people.person', 'name avatarUrl title doNotDisplay sources');
1827
- query.deepPopulate([
1828
- 'people.person.sources.person'
1829
- ], {
1830
- populate: {
1831
- 'people.person.sources.person': { select: 'name avatarUrl title doNotDisplay' }
1832
- }
1810
+ query.populate({
1811
+ path: 'people.person',
1812
+ select: 'name avatarUrl title doNotDisplay sources',
1813
+ populate: { path: 'sources.person', select: 'name avatarUrl title doNotDisplay' }
1833
1814
  });
1834
1815
 
1835
1816
  // get the org requested
@@ -2449,9 +2430,6 @@ module.exports = function(mongoose, config) {
2449
2430
  Organization.index({ website: 1, websiteAliases: 1 }, { unique: true, partialFilterExpression : { type :"string" } });
2450
2431
  Organization.on('index', function(err) { console.log('error building organization_new indexes: ' + err); });
2451
2432
 
2452
- var deepPopulate = require('mongoose-deep-populate')(mongoose);
2453
- Organization.plugin(deepPopulate);
2454
-
2455
2433
  mongoose.model('Organization', Organization, 'organizations');
2456
2434
 
2457
2435
  };
package/lib/Person.js CHANGED
@@ -505,14 +505,8 @@ module.exports = function(mongoose, config) {
505
505
  query.select('notes');
506
506
  query.populate({
507
507
  path: 'notes',
508
- match: { customer: options.CUSTOMER_ID }
509
- });
510
- query.deepPopulate([
511
- 'notes.createdBy'
512
- ], {
513
- populate: {
514
- 'notes.createdBy': { select: 'name avatarUrl title' }
515
- }
508
+ match: { customer: options.CUSTOMER_ID },
509
+ populate: { path: 'createdBy', select: 'name avatarUrl title' }
516
510
  });
517
511
  query.sort({'createdOn':-1});
518
512
 
@@ -1167,9 +1161,6 @@ module.exports = function(mongoose, config) {
1167
1161
 
1168
1162
  });
1169
1163
 
1170
- let deepPopulate = require('mongoose-deep-populate')(mongoose);
1171
- Person.plugin(deepPopulate);
1172
-
1173
1164
  Person.set('autoIndex', false);
1174
1165
  Person.on('index', function(err) { console.log('error building person indexes: ' + err); });
1175
1166
  Person.set('toJSON', { virtuals: true });
package/lib/Round.js CHANGED
@@ -643,15 +643,13 @@ module.exports = function(mongoose, config) {
643
643
  let query = self.find({ 'vehicles.fund': { $in: fundIds } });
644
644
 
645
645
  query.select('organization vehicles');
646
- query.populate('organization', 'name aliases slug logoUrl description contact chairs filters status ipo closed acquired operating website websiteAliases');
647
- query.deepPopulate([
648
- 'organization.chairs.first',
649
- 'organization.chairs.second',
650
- ], {
651
- populate: {
652
- 'organization.chairs.first': { select: 'name avatarUrl title doNotDisplay' },
653
- 'organization.chairs.second': { select: 'name avatarUrl title doNotDisplay' },
654
- }
646
+ query.populate({
647
+ path: 'organization',
648
+ select: 'name aliases slug logoUrl description contact chairs filters status ipo closed acquired operating website websiteAliases',
649
+ populate: [
650
+ { path: 'chairs.first', select: 'name avatarUrl title doNotDisplay' },
651
+ { path: 'chairs.second', select: 'name avatarUrl title doNotDisplay' }
652
+ ]
655
653
  });
656
654
  query.populate('vehicles.fund');
657
655
 
@@ -970,9 +968,6 @@ module.exports = function(mongoose, config) {
970
968
  Round.index({ organization: 1, roundName: 1 }, { unique: true, partialFilterExpression : { type :"string" } });
971
969
  Round.on('index', function(err) { console.log('error building Round indexes: ' + err); });
972
970
 
973
- var deepPopulate = require('mongoose-deep-populate')(mongoose);
974
- Round.plugin(deepPopulate);
975
-
976
971
  mongoose.model('Round', Round);
977
972
 
978
973
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "12.0.0",
3
+ "version": "12.1.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -21,7 +21,6 @@
21
21
  "awesome-phonenumber": "^1.0.14",
22
22
  "escape-string-regexp": "^1.0.5",
23
23
  "moment": "^2.30.1",
24
- "mongoose-deep-populate": "^3.2.0",
25
24
  "range_check": "^1.4.0",
26
25
  "underscore": "^1.13.6",
27
26
  "validator": "^13.11.0"