@dhyasama/totem-models 9.45.5 → 9.47.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 +19 -0
- package/lib/Organization.js +1 -1
- package/package.json +1 -1
package/lib/Message.js
CHANGED
|
@@ -228,6 +228,25 @@ module.exports = function(mongoose, config) {
|
|
|
228
228
|
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
+
Message.statics.getMostRecentForOrg = function getMostRecentForOrg(orgId, options, cb) {
|
|
232
|
+
|
|
233
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
234
|
+
if (!orgId) { return cb(new Error('orgId is required'), null); }
|
|
235
|
+
if (!mongoose.Types.ObjectId.isValid(orgId)) { return cb(new Error('orgId is not a valid ObjectId'), null); }
|
|
236
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
237
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
238
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
239
|
+
|
|
240
|
+
// Note - This filters by customer so is NOT usable by admin tools
|
|
241
|
+
|
|
242
|
+
const self = this;
|
|
243
|
+
|
|
244
|
+
let query = self.find({ customer: options.CUSTOMER_ID, organization: orgId }).sort({'originalMessageDate': -1}).limit(1);
|
|
245
|
+
|
|
246
|
+
query.exec(cb);
|
|
247
|
+
|
|
248
|
+
};
|
|
249
|
+
|
|
231
250
|
Message.statics.getForPeople = function getForPeople(personIds, options, cb) {
|
|
232
251
|
|
|
233
252
|
if (!cb) { throw new Error('cb is required'); }
|
package/lib/Organization.js
CHANGED
|
@@ -171,7 +171,7 @@ module.exports = function(mongoose, config) {
|
|
|
171
171
|
|
|
172
172
|
premium: { type: Boolean, default: false },
|
|
173
173
|
|
|
174
|
-
totemUrl: { type: String, trim: true, unique:
|
|
174
|
+
totemUrl: { type: String, trim: true, unique: false, partialFilterExpression : { type :"string" } },
|
|
175
175
|
|
|
176
176
|
logos: {
|
|
177
177
|
light: { type: String, trim: true },
|