@dhyasama/totem-models 11.51.0 → 11.52.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/LimitedPartner.js +29 -0
- package/lib/Organization.js +13 -0
- package/package.json +1 -1
package/lib/LimitedPartner.js
CHANGED
|
@@ -519,6 +519,35 @@ module.exports = function(mongoose, config) {
|
|
|
519
519
|
|
|
520
520
|
};
|
|
521
521
|
|
|
522
|
+
LimitedPartner.statics.getByPersonIds = function(personIds, options, cb) {
|
|
523
|
+
|
|
524
|
+
const self = this;
|
|
525
|
+
|
|
526
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
527
|
+
if (!personIds) { return cb(new Error('personIds is required'), null); }
|
|
528
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
529
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
530
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
531
|
+
|
|
532
|
+
options = helpers.getDefaultOptions(options);
|
|
533
|
+
|
|
534
|
+
let query;
|
|
535
|
+
|
|
536
|
+
if (options.isWorkerProcess) {
|
|
537
|
+
query = self.find({'people': { $in : personIds }}, getReadFilterKeys(options.role));
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
query = self.find({'people': { $in : personIds }, customer: options.CUSTOMER_ID }, getReadFilterKeys(options.role));
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
query.exec(function (err, lps) {
|
|
544
|
+
if (err) { return cb(err, null); }
|
|
545
|
+
lps = _.sortBy(lps, function(lp) { return lp.name ? lp.name.toLowerCase() : ''; });
|
|
546
|
+
return cb(null, lps);
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
};
|
|
550
|
+
|
|
522
551
|
LimitedPartner.statics.getFlags = function getFlags(lpid, options, cb) {
|
|
523
552
|
|
|
524
553
|
const self = this;
|
package/lib/Organization.js
CHANGED
|
@@ -1282,6 +1282,19 @@ module.exports = function(mongoose, config) {
|
|
|
1282
1282
|
|
|
1283
1283
|
};
|
|
1284
1284
|
|
|
1285
|
+
Organization.statics.getByPersonIds = function getByPersonIds(personIds, cb) {
|
|
1286
|
+
|
|
1287
|
+
const self = this;
|
|
1288
|
+
|
|
1289
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
1290
|
+
if (!personIds) { return cb(new Error('personIds is required'), null); }
|
|
1291
|
+
|
|
1292
|
+
self
|
|
1293
|
+
.find({'people.person': { $in : personIds } })
|
|
1294
|
+
.exec(cb);
|
|
1295
|
+
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1285
1298
|
Organization.statics.findBySlug = function findBySlug(slug, cb) {
|
|
1286
1299
|
this.findOne({ slug: slug, 'deleted': {$ne: true} }).exec(cb);
|
|
1287
1300
|
};
|