@dhyasama/totem-models 11.16.0 → 11.17.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/Round.js +38 -0
  2. package/package.json +1 -1
package/lib/Round.js CHANGED
@@ -391,6 +391,44 @@ module.exports = function(mongoose, config) {
391
391
 
392
392
  };
393
393
 
394
+ Round.statics.getByOrgs2 = function getByOrg2(orgIds, options, cb) {
395
+
396
+ const self = this;
397
+
398
+ if (!cb) { throw new Error('cb is required'); }
399
+ if (!orgIds) { throw new Error('orgIds is required'); }
400
+ if (!options) { return cb(new Error('options is required'), null); }
401
+
402
+ options = helpers.getDefaultOptions(options);
403
+
404
+ if (!options.isWorkerProcess) {
405
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
406
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
407
+ }
408
+
409
+ let query = self.find({
410
+ 'organization': { $in: orgIds }
411
+ });
412
+
413
+ if (options.isWorkerProcess) {
414
+ query.populate('vehicles.investments');
415
+ }
416
+ else {
417
+ query.populate({
418
+ path: 'vehicles.investments',
419
+ match: { customer: options.CUSTOMER_ID }
420
+ });
421
+ }
422
+
423
+ query.exec(function(err, rounds) {
424
+
425
+ if (err) return cb(err, null);
426
+ return cb(null, rounds);
427
+
428
+ });
429
+
430
+ };
431
+
394
432
  Round.statics.getFundInvestments = function getFundInvestments(fundId, options, cb) {
395
433
 
396
434
  const self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "11.16.0",
3
+ "version": "11.17.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",