@dhyasama/totem-models 8.9.0 → 8.11.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/index.js CHANGED
@@ -10,13 +10,6 @@ var bootstrap = function(mongoose, config) {
10
10
  // use bluebird promises globally within mongoose
11
11
  mongoose.Promise = require('bluebird');
12
12
 
13
- // Validate config
14
- var configHas_LPS_ENABLED = typeof config['LPS_ENABLED'] != 'undefined';
15
- if (!configHas_LPS_ENABLED) throw new Error('Config is missing LPS_ENABLED setting');
16
-
17
- var configHas_CUSTOMER_ID = typeof config['CUSTOMER_ID'] != 'undefined';
18
- if (!configHas_CUSTOMER_ID) throw new Error('Config is missing CUSTOMER_ID setting');
19
-
20
13
  // todo - find a solution to load without worrying about order
21
14
 
22
15
  // deal must be loaded before organization
@@ -391,13 +391,21 @@ module.exports = function(mongoose, config) {
391
391
  const self = this;
392
392
 
393
393
  if (!cb) { throw new Error('cb is required'); }
394
- if (!lpName) { return cb(new Error('lpName is required'), null); }
394
+ if (!options) { return cb(new Error('options is required'), null); }
395
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
396
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
395
397
 
396
398
  options = helpers.getDefaultOptions(options);
397
399
 
398
- if (!options.isWorkerProcess) { return cb(null, []); }
400
+ let query;
401
+
402
+ if (!options.isWorkerProcess) {
403
+ return cb(null, []);
404
+ }
399
405
 
400
- let query = self.findOne({'name': lpName}, this.getReadFilterKeys(options.role));
406
+ else {
407
+ query = self.findOne({'name': lpName, customer: options.CUSTOMER_ID }, self.getReadFilterKeys(options.role));
408
+ }
401
409
 
402
410
  query.populate('transactions.fund');
403
411
  query.exec(cb);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.9.0",
3
+ "version": "8.11.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",