@dhyasama/totem-models 5.7.0 → 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 ADDED
@@ -0,0 +1,14 @@
1
+ lib-cov
2
+ *.seed
3
+ *.log
4
+ *.csv
5
+ *.dat
6
+ *.out
7
+ *.pid
8
+ *.gz
9
+
10
+ npm-debug.log
11
+ node_modules
12
+
13
+ .DS_Store
14
+ .idea
package/lib/Deal.js CHANGED
@@ -21,7 +21,7 @@ module.exports = function(mongoose, config) {
21
21
 
22
22
  sources: [{
23
23
  person: { type: Schema.ObjectId, ref: 'Person', required: true },
24
- type: { type: String, enum: ['Inbound', 'Outbound', 'Event', 'Referral', 'Other'], required: true }
24
+ type: { type: String, enum: ['Cold Inbound', 'Cold Outbound', 'Met at Event', 'Was Referred', 'Other'], required: true }
25
25
  }],
26
26
 
27
27
  referrers: [{
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
- message.createdOn = new Date();
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
- email = email.toLowerCase();
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) {