@dhyasama/totem-models 10.68.0 → 10.70.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/Message.js CHANGED
@@ -236,6 +236,23 @@ module.exports = function(mongoose, config) {
236
236
 
237
237
  };
238
238
 
239
+ Message.statics.getForOrgs = function(orgIds, options, cb) {
240
+
241
+ if (!cb) { throw new Error('cb is required'); }
242
+ if (!orgIds) { return cb(new Error('orgIds is required'), null); }
243
+ if (!options) { return cb(new Error('options is required'), null); }
244
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
245
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
246
+
247
+ const self = this;
248
+
249
+ let query = self.find({ customer: options.CUSTOMER_ID, organization: { $in : orgIds } });
250
+ query.populate('documents');
251
+
252
+ query.exec(cb);
253
+
254
+ };
255
+
239
256
  Message.statics.getMostRecent = function getMostRecent(orgId, personIds, options, cb) {
240
257
 
241
258
  if (!cb) { throw new Error('cb is required'); }
@@ -1579,6 +1579,35 @@ module.exports = function(mongoose, config) {
1579
1579
 
1580
1580
  };
1581
1581
 
1582
+ Organization.statics.getByIds = function getByIds(ids, options, cb) {
1583
+
1584
+ const self = this;
1585
+
1586
+ if (!cb) { throw new Error('cb is required'); }
1587
+ if (!ids) { return cb(new Error('ids is required'), null); }
1588
+ if (!options) { return cb(new Error('options is required'), null); }
1589
+
1590
+ options = helpers.getDefaultOptions(options);
1591
+
1592
+ if (!options.isWorkerProcess) {
1593
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
1594
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
1595
+ }
1596
+
1597
+ let query = self.find( {'_id': { $in : ids } } );
1598
+ query.populate('documents');
1599
+
1600
+ query.exec(function(err, result) {
1601
+
1602
+ if (err) { return cb(err, null); }
1603
+
1604
+ if (options.isWorkerProcess) { return cb(null, result); }
1605
+ else { return cb(null, _.map(result, function(r) { return helpers.cleanOrg(r, options.CUSTOMER_ID) })) }
1606
+
1607
+ });
1608
+
1609
+ };
1610
+
1582
1611
  Organization.statics.getChairsOfPerson = function getChairsOfPerson(personId, options, cb) {
1583
1612
 
1584
1613
  const self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "10.68.0",
3
+ "version": "10.70.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",