@dhyasama/totem-models 5.7.1 → 5.8.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/.npmignore +14 -0
- package/lib/Message.js +8 -1
- package/lib/Person.js +7 -1
- package/package-lock.json +1854 -0
- package/package.json +1 -1
- package/test/Message.js +25 -0
- package/test/Person.js +39 -0
package/.npmignore
ADDED
package/lib/Message.js
CHANGED
|
@@ -15,6 +15,7 @@ module.exports = function(mongoose, config) {
|
|
|
15
15
|
var Message = new Schema({
|
|
16
16
|
|
|
17
17
|
createdOn: { type: Date, required: true },
|
|
18
|
+
updatedOn: { type: Date, required: true },
|
|
18
19
|
webhook: { type: Schema.ObjectId, ref: 'Webhook', required: true },
|
|
19
20
|
type: { type: String, required: true, enum: ['email'], default: 'email' }, // for future options
|
|
20
21
|
subtype: { type: String, required: true, enum: ['boards', 'updates', 'deals', 'portfolio'] },
|
|
@@ -295,8 +296,14 @@ module.exports = function(mongoose, config) {
|
|
|
295
296
|
};
|
|
296
297
|
|
|
297
298
|
Message.statics.upsert = function(message, cb) {
|
|
298
|
-
|
|
299
|
+
|
|
300
|
+
var timestamp = new Date();
|
|
301
|
+
|
|
302
|
+
message.createdOn = message.createdOn || timestamp;
|
|
303
|
+
message.updatedOn = timestamp;
|
|
304
|
+
|
|
299
305
|
message.save(cb);
|
|
306
|
+
|
|
300
307
|
};
|
|
301
308
|
|
|
302
309
|
///////////////////////////////////////
|
package/lib/Person.js
CHANGED
|
@@ -636,10 +636,16 @@ module.exports = function(mongoose, config) {
|
|
|
636
636
|
};
|
|
637
637
|
|
|
638
638
|
Person.statics.searchByEmail = function(email, cb) {
|
|
639
|
-
|
|
639
|
+
|
|
640
|
+
if (!cb) throw new Error('cb is required');
|
|
641
|
+
if (!email) return cb(new Error('email is required to search by email'), null);
|
|
642
|
+
|
|
643
|
+
email = email.toString().toLowerCase();
|
|
644
|
+
|
|
640
645
|
this
|
|
641
646
|
.find({ 'contact.email.email': email, 'deleted': {$ne: true} })
|
|
642
647
|
.exec(cb);
|
|
648
|
+
|
|
643
649
|
};
|
|
644
650
|
|
|
645
651
|
Person.statics.findDupes = function(person, options, cb) {
|