@dhyasama/totem-models 12.6.0 → 12.7.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/Account.js CHANGED
@@ -391,7 +391,11 @@ module.exports = function(mongoose, config) {
391
391
  // No population so no need to scrub
392
392
 
393
393
  const run = async () => {
394
- const result = await account.save();
394
+ if (typeof account.save === 'function') {
395
+ return await account.save();
396
+ }
397
+ const { _id, ...update } = account;
398
+ const result = await this.findByIdAndUpdate(_id, update, { new: true });
395
399
  return result;
396
400
  };
397
401
 
package/lib/Activity.js CHANGED
@@ -78,7 +78,7 @@ module.exports = function(mongoose, config) {
78
78
  }
79
79
  };
80
80
 
81
- if (typeof callback === 'function') { run().then(result => callback(null, result)).catch(callback); }
81
+ if (typeof callback === 'function') { run().then(result => callback(null, result)).catch(callback); return; }
82
82
  else { return run(); }
83
83
 
84
84
  };
@@ -218,6 +218,10 @@ module.exports = function(mongoose, config) {
218
218
  CalendarEvent.statics.upsert = function(calendarEvent, cb) {
219
219
 
220
220
  const run = async () => {
221
+ if (typeof calendarEvent.save === 'function') {
222
+ return await calendarEvent.save();
223
+ }
224
+
221
225
  // Prevent dupe events
222
226
 
223
227
  var query = { 'email': calendarEvent.email, 'eventId': calendarEvent.eventId };
package/lib/CapTable.js CHANGED
@@ -503,8 +503,11 @@ module.exports = function(mongoose, config) {
503
503
  const run = async () => {
504
504
  if (!capTable) { throw new Error('cap table is required'); }
505
505
 
506
- const result = await capTable.save();
507
- return result;
506
+ if (typeof capTable.save === 'function') {
507
+ return await capTable.save();
508
+ }
509
+ const { _id, ...update } = capTable;
510
+ return await this.findByIdAndUpdate(_id, update, { new: true });
508
511
  };
509
512
 
510
513
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Deal.js CHANGED
@@ -829,10 +829,15 @@ module.exports = function(mongoose, config) {
829
829
  }
830
830
 
831
831
  // Required for mixed types
832
- deal.markModified('customFields');
832
+ if (typeof deal.markModified === 'function') {
833
+ deal.markModified('customFields');
834
+ }
833
835
 
834
- const result = await deal.save();
835
- return result;
836
+ if (typeof deal.save === 'function') {
837
+ return await deal.save();
838
+ }
839
+ const { _id, ...update } = deal;
840
+ return await this.findByIdAndUpdate(_id, update, { new: true });
836
841
  };
837
842
 
838
843
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -61,9 +61,12 @@ module.exports = function(mongoose, config) {
61
61
 
62
62
  const run = async () => {
63
63
  doc.updatedOn = new Date();
64
- doc.markModified('entity');
65
- const result = await doc.save();
66
- return result;
64
+ if (typeof doc.save === 'function') {
65
+ doc.markModified('entity');
66
+ return await doc.save();
67
+ }
68
+ const { _id, ...update } = doc;
69
+ return await this.findByIdAndUpdate(_id, update, { new: true });
67
70
  };
68
71
 
69
72
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -60,9 +60,12 @@ module.exports = function(mongoose, config) {
60
60
 
61
61
  const run = async () => {
62
62
  doc.updatedOn = new Date();
63
- doc.markModified('entity');
64
- const result = await doc.save();
65
- return result;
63
+ if (typeof doc.save === 'function') {
64
+ doc.markModified('entity');
65
+ return await doc.save();
66
+ }
67
+ const { _id, ...update } = doc;
68
+ return await this.findByIdAndUpdate(_id, update, { new: true });
66
69
  };
67
70
 
68
71
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Document.js CHANGED
@@ -275,8 +275,11 @@ module.exports = function(mongoose, config) {
275
275
 
276
276
  // No population so no need to scrub
277
277
 
278
- const result = await doc.save();
279
- return result;
278
+ if (typeof doc.save === 'function') {
279
+ return await doc.save();
280
+ }
281
+ const { _id, ...update } = doc;
282
+ return await this.findByIdAndUpdate(_id, update, { new: true });
280
283
  };
281
284
 
282
285
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Event.js CHANGED
@@ -148,8 +148,11 @@ module.exports = function(mongoose, config) {
148
148
  if (!event) throw new Error('event is required');
149
149
  if (!options) { throw new Error('options is required'); }
150
150
 
151
- const result = await event.save();
152
- return result;
151
+ if (typeof event.save === 'function') {
152
+ return await event.save();
153
+ }
154
+ const { _id, ...update } = event;
155
+ return await this.findByIdAndUpdate(_id, update, { new: true });
153
156
  };
154
157
 
155
158
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -134,8 +134,11 @@ module.exports = function(mongoose, config) {
134
134
  const run = async () => {
135
135
  if (!eventAttendee) throw new Error('eventAttendee is required');
136
136
 
137
- const result = await eventAttendee.save();
138
- return result;
137
+ if (typeof eventAttendee.save === 'function') {
138
+ return await eventAttendee.save();
139
+ }
140
+ const { _id, ...update } = eventAttendee;
141
+ return await this.findByIdAndUpdate(_id, update, { new: true });
139
142
  };
140
143
 
141
144
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Financials.js CHANGED
@@ -1230,8 +1230,11 @@ module.exports = function(mongoose, config) {
1230
1230
  const run = async () => {
1231
1231
  if (!financials) { throw new Error('financials is required'); }
1232
1232
 
1233
- const result = await financials.save();
1234
- return result;
1233
+ if (typeof financials.save === 'function') {
1234
+ return await financials.save();
1235
+ }
1236
+ const { _id, ...update } = financials;
1237
+ return await this.findByIdAndUpdate(_id, update, { new: true });
1235
1238
  };
1236
1239
 
1237
1240
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -108,8 +108,11 @@ module.exports = function(mongoose, config) {
108
108
  const run = async () => {
109
109
  if (!doc) { throw new Error('doc is required'); }
110
110
 
111
- const result = await doc.save();
112
- return result;
111
+ if (typeof doc.save === 'function') {
112
+ return await doc.save();
113
+ }
114
+ const { _id, ...update } = doc;
115
+ return await this.findByIdAndUpdate(_id, update, { new: true });
113
116
  };
114
117
 
115
118
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Flag.js CHANGED
@@ -114,8 +114,11 @@ module.exports = function(mongoose, config) {
114
114
  Flag.statics.upsert = function(flag, cb) {
115
115
 
116
116
  const run = async () => {
117
- const result = await flag.save();
118
- return result;
117
+ if (typeof flag.save === 'function') {
118
+ return await flag.save();
119
+ }
120
+ const { _id, ...update } = flag;
121
+ return await this.findByIdAndUpdate(_id, update, { new: true });
119
122
  };
120
123
 
121
124
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Folder.js CHANGED
@@ -67,8 +67,11 @@ module.exports = function(mongoose, config) {
67
67
  Folder.statics.upsert = function (folder, cb) {
68
68
 
69
69
  const run = async () => {
70
- const result = await folder.save();
71
- return result;
70
+ if (typeof folder.save === 'function') {
71
+ return await folder.save();
72
+ }
73
+ const { _id, ...update } = folder;
74
+ return await this.findByIdAndUpdate(_id, update, { new: true });
72
75
  };
73
76
 
74
77
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Fund.js CHANGED
@@ -212,11 +212,13 @@ module.exports = function(mongoose, config) {
212
212
  if (!fund) { throw new Error('Fund is required'); }
213
213
  if (!username) { throw new Error('Username is required'); }
214
214
 
215
- // Required for mixed types
216
- fund.markModified('customFields');
217
-
218
- const result = await fund.save();
219
- return result;
215
+ if (typeof fund.save === 'function') {
216
+ // Required for mixed types
217
+ fund.markModified('customFields');
218
+ return await fund.save();
219
+ }
220
+ const { _id, ...update } = fund;
221
+ return await this.findByIdAndUpdate(_id, update, { new: true });
220
222
  };
221
223
 
222
224
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -429,8 +429,11 @@ module.exports = function(mongoose, config) {
429
429
  const run = async () => {
430
430
  if (!interaction) { throw new Error('Interaction is required'); }
431
431
 
432
- const result = await interaction.save();
433
- return result;
432
+ if (typeof interaction.save === 'function') {
433
+ return await interaction.save();
434
+ }
435
+ const { _id, ...update } = interaction;
436
+ return await this.findByIdAndUpdate(_id, update, { new: true });
434
437
  };
435
438
 
436
439
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Investment.js CHANGED
@@ -146,13 +146,15 @@ module.exports = function(mongoose, config) {
146
146
  Investment.statics.upsert = function upsert(investment, cb) {
147
147
 
148
148
  const run = async () => {
149
- // Required for mixed types
150
- investment.markModified('details');
151
-
152
149
  if (!investment) { throw new Error('investment is required'); }
153
150
 
154
- const result = await investment.save();
155
- return result;
151
+ if (typeof investment.save === 'function') {
152
+ // Required for mixed types
153
+ investment.markModified('details');
154
+ return await investment.save();
155
+ }
156
+ const { _id, ...update } = investment;
157
+ return await this.findByIdAndUpdate(_id, update, { new: true });
156
158
  };
157
159
 
158
160
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -889,15 +889,18 @@ module.exports = function(mongoose, config) {
889
889
  if (!options.role) { throw new Error('options.role is required'); }
890
890
  if (options.role !== 'admin' && options.role !== 'lp-full') { throw new Error('options.role is not valid'); }
891
891
 
892
+ lp.entered = lp.entered || {};
892
893
  lp.entered.by = username;
893
894
  lp.entered.on = new Date();
894
895
 
895
- // Required for mixed types
896
- lp.markModified('details');
897
- lp.markModified('customFields');
898
-
899
- const result = await lp.save();
900
- return result;
896
+ if (typeof lp.save === 'function') {
897
+ // Required for mixed types
898
+ lp.markModified('details');
899
+ lp.markModified('customFields');
900
+ return await lp.save();
901
+ }
902
+ const { _id, ...update } = lp;
903
+ return await this.findByIdAndUpdate(_id, update, { new: true });
901
904
  };
902
905
 
903
906
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -167,8 +167,11 @@ module.exports = function(mongoose, config) {
167
167
  const run = async () => {
168
168
  if (!doc) { throw new Error('doc is required'); }
169
169
 
170
- const result = await doc.save();
171
- return result;
170
+ if (typeof doc.save === 'function') {
171
+ return await doc.save();
172
+ }
173
+ const { _id, ...update } = doc;
174
+ return await this.findByIdAndUpdate(_id, update, { new: true });
172
175
  };
173
176
 
174
177
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -260,8 +260,11 @@ module.exports = function(mongoose, config) {
260
260
  const run = async () => {
261
261
  if (!doc) { throw new Error('doc is required'); }
262
262
 
263
- const result = await doc.save();
264
- return result;
263
+ if (typeof doc.save === 'function') {
264
+ return await doc.save();
265
+ }
266
+ const { _id, ...update } = doc;
267
+ return await this.findByIdAndUpdate(_id, update, { new: true });
265
268
  };
266
269
 
267
270
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -94,8 +94,11 @@ module.exports = function(mongoose, config) {
94
94
  const run = async () => {
95
95
  if (!doc) { throw new Error('doc is required'); }
96
96
 
97
- const result = await doc.save();
98
- return result;
97
+ if (typeof doc.save === 'function') {
98
+ return await doc.save();
99
+ }
100
+ const { _id, ...update } = doc;
101
+ return await this.findByIdAndUpdate(_id, update, { new: true });
99
102
  };
100
103
 
101
104
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -73,8 +73,11 @@ module.exports = function(mongoose, config) {
73
73
  const run = async () => {
74
74
  if (!doc) { throw new Error('doc is required'); }
75
75
 
76
- const result = await doc.save();
77
- return result;
76
+ if (typeof doc.save === 'function') {
77
+ return await doc.save();
78
+ }
79
+ const { _id, ...update } = doc;
80
+ return await this.findByIdAndUpdate(_id, update, { new: true });
78
81
  };
79
82
 
80
83
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/List.js CHANGED
@@ -245,8 +245,11 @@ module.exports = function(mongoose, config) {
245
245
  List.statics.upsert = function (list, cb) {
246
246
 
247
247
  const run = async () => {
248
- const result = await list.save();
249
- return result;
248
+ if (typeof list.save === 'function') {
249
+ return await list.save();
250
+ }
251
+ const { _id, ...update } = list;
252
+ return await this.findByIdAndUpdate(_id, update, { new: true });
250
253
  };
251
254
 
252
255
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Meeting.js CHANGED
@@ -178,8 +178,11 @@ module.exports = function(mongoose, config) {
178
178
  const run = async () => {
179
179
  if (!meeting) { throw new Error('Meeting is required'); }
180
180
 
181
- const result = await meeting.save();
182
- return result;
181
+ if (typeof meeting.save === 'function') {
182
+ return await meeting.save();
183
+ }
184
+ const { _id, ...update } = meeting;
185
+ return await this.findByIdAndUpdate(_id, update, { new: true });
183
186
  };
184
187
 
185
188
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Message.js CHANGED
@@ -452,8 +452,11 @@ module.exports = function(mongoose, config) {
452
452
  // The original message date isn't always contained in the email. In its absence, use created on.
453
453
  message.messageDate = message.messageDate || message.originalMessageDate || message.createdOn;
454
454
 
455
- const result = await message.save();
456
- return result;
455
+ if (typeof message.save === 'function') {
456
+ return await message.save();
457
+ }
458
+ const { _id, ...update } = message;
459
+ return await this.findByIdAndUpdate(_id, update, { new: true });
457
460
  };
458
461
 
459
462
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -88,8 +88,11 @@ module.exports = function(mongoose, config) {
88
88
  MessageRecipient.statics.upsert = function(message, cb) {
89
89
 
90
90
  const run = async () => {
91
- const result = await message.save();
92
- return result;
91
+ if (typeof message.save === 'function') {
92
+ return await message.save();
93
+ }
94
+ const { _id, ...update } = message;
95
+ return await this.findByIdAndUpdate(_id, update, { new: true });
93
96
  };
94
97
 
95
98
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/News.js CHANGED
@@ -115,8 +115,11 @@ module.exports = function(mongoose, config) {
115
115
  News.statics.upsert = function (news, cb) {
116
116
 
117
117
  const run = async () => {
118
- const result = await news.save();
119
- return result;
118
+ if (typeof news.save === 'function') {
119
+ return await news.save();
120
+ }
121
+ const { _id, ...update } = news;
122
+ return await this.findByIdAndUpdate(_id, update, { new: true });
120
123
  };
121
124
 
122
125
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Note.js CHANGED
@@ -125,8 +125,11 @@ module.exports = function(mongoose, config) {
125
125
  Note.statics.upsert = function(note, cb) {
126
126
 
127
127
  const run = async () => {
128
- const result = await note.save();
129
- return result;
128
+ if (typeof note.save === 'function') {
129
+ return await note.save();
130
+ }
131
+ const { _id, ...update } = note;
132
+ return await this.findByIdAndUpdate(_id, update, { new: true });
130
133
  };
131
134
 
132
135
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
@@ -2282,8 +2282,11 @@ module.exports = function(mongoose, config) {
2282
2282
  // Clean up missing references
2283
2283
  //org.people = _.reject(org.people, function(item) { return !item.person; });
2284
2284
 
2285
- const result = await org.save();
2286
- return result;
2285
+ if (typeof org.save === 'function') {
2286
+ return await org.save();
2287
+ }
2288
+ const { _id, ...update } = org;
2289
+ return await this.findByIdAndUpdate(_id, update, { new: true });
2287
2290
  };
2288
2291
 
2289
2292
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Person.js CHANGED
@@ -1072,8 +1072,11 @@ module.exports = function(mongoose, config) {
1072
1072
  on: new Date()
1073
1073
  };
1074
1074
 
1075
- const result = await currentPerson.save();
1076
- return result;
1075
+ if (typeof currentPerson.save === 'function') {
1076
+ return await currentPerson.save();
1077
+ }
1078
+ const { _id, ...update } = currentPerson;
1079
+ return await this.findByIdAndUpdate(_id, update, { new: true });
1077
1080
  };
1078
1081
 
1079
1082
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Rate.js CHANGED
@@ -52,8 +52,11 @@ module.exports = function(mongoose, config) {
52
52
  Rate.statics.upsert = function (rate, cb) {
53
53
 
54
54
  const run = async () => {
55
- const result = await rate.save();
56
- return result;
55
+ if (typeof rate.save === 'function') {
56
+ return await rate.save();
57
+ }
58
+ const { _id, ...update } = rate;
59
+ return await this.findByIdAndUpdate(_id, update, { new: true });
57
60
  };
58
61
 
59
62
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Round.js CHANGED
@@ -955,8 +955,11 @@ module.exports = function(mongoose, config) {
955
955
  const run = async () => {
956
956
  if (!round) { throw new Error('round is required'); }
957
957
 
958
- const result = await round.save();
959
- return result;
958
+ if (typeof round.save === 'function') {
959
+ return await round.save();
960
+ }
961
+ const { _id, ...update } = round;
962
+ return await this.findByIdAndUpdate(_id, update, { new: true });
960
963
  };
961
964
 
962
965
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Snapshot.js CHANGED
@@ -28,8 +28,11 @@ module.exports = function(mongoose, config) {
28
28
  Snapshot.statics.upsert = function(snapshot, cb) {
29
29
 
30
30
  const run = async () => {
31
- const result = await snapshot.save();
32
- return result;
31
+ if (typeof snapshot.save === 'function') {
32
+ return await snapshot.save();
33
+ }
34
+ const { _id, ...update } = snapshot;
35
+ return await this.findByIdAndUpdate(_id, update, { new: true });
33
36
  };
34
37
 
35
38
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Sync.js CHANGED
@@ -43,8 +43,11 @@ module.exports = function(mongoose, config) {
43
43
 
44
44
  const run = async () => {
45
45
  sync.syncedOn = new Date();
46
- const result = await sync.save();
47
- return result;
46
+ if (typeof sync.save === 'function') {
47
+ return await sync.save();
48
+ }
49
+ const { _id, ...update } = sync;
50
+ return await this.findByIdAndUpdate(_id, update, { new: true });
48
51
  };
49
52
 
50
53
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/lib/Webhook.js CHANGED
@@ -20,8 +20,11 @@ module.exports = function(mongoose, config) {
20
20
 
21
21
  const run = async () => {
22
22
  webhook.createdOn = new Date();
23
- const result = await webhook.save();
24
- return result;
23
+ if (typeof webhook.save === 'function') {
24
+ return await webhook.save();
25
+ }
26
+ const { _id, ...update } = webhook;
27
+ return await this.findByIdAndUpdate(_id, update, { new: true });
25
28
  };
26
29
 
27
30
  if (typeof cb === 'function') { run().then(result => cb(null, result)).catch(cb); return; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "12.6.0",
3
+ "version": "12.7.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",