@dhyasama/totem-models 1.21.1 → 1.22.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/List.js CHANGED
@@ -122,6 +122,48 @@ module.exports = function(mongoose, config) {
122
122
  .exec(cb);
123
123
  };
124
124
 
125
+ // Get all lists that contain an lp
126
+ List.statics.getByLP = function(lpId, cb) {
127
+
128
+ var self = this;
129
+
130
+ self
131
+ .find({ 'customer': config.CUSTOMER_ID, limitedPartners: lpId })
132
+ .populate('limitedPartners', 'name logoUrl')
133
+ .populate('organizations', 'name logoUrl')
134
+ .populate('people', 'name title avatarUrl')
135
+ .exec(cb);
136
+
137
+ };
138
+
139
+ // Get all lists that contain an org
140
+ List.statics.getByOrg = function(orgId, cb) {
141
+
142
+ var self = this;
143
+
144
+ self
145
+ .find({ 'customer': config.CUSTOMER_ID, organizations: orgId })
146
+ .populate('limitedPartners', 'name logoUrl')
147
+ .populate('organizations', 'name logoUrl')
148
+ .populate('people', 'name title avatarUrl')
149
+ .exec(cb);
150
+
151
+ };
152
+
153
+ // Get all lists that contain a person
154
+ List.statics.getByPerson = function(personId, cb) {
155
+
156
+ var self = this;
157
+
158
+ self
159
+ .find({ 'customer': config.CUSTOMER_ID, people: personId })
160
+ .populate('limitedPartners', 'name logoUrl')
161
+ .populate('organizations', 'name logoUrl')
162
+ .populate('people', 'name title avatarUrl')
163
+ .exec(cb);
164
+
165
+ };
166
+
125
167
  List.statics.getLists = function(cb) {
126
168
 
127
169
  var self = this;
@@ -156,6 +198,10 @@ module.exports = function(mongoose, config) {
156
198
 
157
199
  };
158
200
 
201
+ List.statics.upsert = function (list, cb) {
202
+ list.save(cb);
203
+ };
204
+
159
205
  List.pre('save', function(next) {
160
206
 
161
207
  var self = this;
package/lib/Round.js CHANGED
@@ -513,7 +513,8 @@ module.exports = function(mongoose, config) {
513
513
  var self = this;
514
514
 
515
515
  var query = self.find({ 'vehicles.fund': fundId });
516
- query.select('vehicles');
516
+ query.select('organization roundName vehicles');
517
+ query.populate('organization', 'name logoUrl');
517
518
 
518
519
  if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
519
520
  query.populate('vehicles.investments');
@@ -530,10 +531,21 @@ module.exports = function(mongoose, config) {
530
531
  if (err) return cb(err, null);
531
532
  if (!rounds) return cb(null, []);
532
533
 
533
- var vehicles = _.flatten(_.pluck(rounds, 'vehicles'));
534
- var investments = _.flatten(_.pluck(vehicles, 'investments'));
534
+ var fundInvestments = [];
535
+
536
+ _.each(rounds, function(round) {
537
+ _.each(round.vehicles, function(vehicle) {
538
+ if(vehicle.fund == fundId) {
539
+ _.each(vehicle.investments, function(investment) {
540
+ investment.organization = round.organization;
541
+ investment.roundName = round.roundName;
542
+ fundInvestments.push(investment);
543
+ });
544
+ }
545
+ });
546
+ });
535
547
 
536
- return cb(null, investments);
548
+ return cb(null, fundInvestments);
537
549
 
538
550
  });
539
551
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.21.1",
3
+ "version": "1.22.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",