@dhyasama/totem-models 12.5.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 +11 -7
- package/lib/Activity.js +1 -1
- package/lib/CalendarEvent.js +4 -0
- package/lib/CapTable.js +5 -2
- package/lib/Deal.js +8 -3
- package/lib/DiffbotArticle.js +6 -3
- package/lib/DiffbotOrganization.js +6 -3
- package/lib/Document.js +5 -2
- package/lib/Event.js +5 -2
- package/lib/EventAttendee.js +5 -2
- package/lib/Financials.js +5 -2
- package/lib/FinancialsAnalysis.js +5 -2
- package/lib/Flag.js +5 -2
- package/lib/Folder.js +5 -2
- package/lib/Fund.js +7 -5
- package/lib/Interaction.js +5 -2
- package/lib/Investment.js +7 -5
- package/lib/LimitedPartner.js +9 -6
- package/lib/LimitedPartnerCampaign.js +5 -2
- package/lib/LimitedPartnerCommunication.js +5 -2
- package/lib/LimitedPartnerContactGroup.js +5 -2
- package/lib/LimitedPartnerReportGenerator.js +5 -2
- package/lib/List.js +5 -2
- package/lib/Meeting.js +5 -2
- package/lib/Message.js +5 -2
- package/lib/MessageRecipient.js +5 -2
- package/lib/News.js +5 -2
- package/lib/Note.js +5 -2
- package/lib/Organization.js +5 -2
- package/lib/Person.js +5 -2
- package/lib/Rate.js +5 -2
- package/lib/Round.js +5 -2
- package/lib/Snapshot.js +5 -2
- package/lib/Sync.js +5 -2
- package/lib/Webhook.js +5 -2
- package/package.json +1 -1
package/lib/Account.js
CHANGED
|
@@ -110,7 +110,7 @@ module.exports = function(mongoose, config) {
|
|
|
110
110
|
const account = await this.findOne(query).populate('person').lean({ virtuals: true });
|
|
111
111
|
if (!account) { return null; }
|
|
112
112
|
|
|
113
|
-
if (account.
|
|
113
|
+
if (account.person && typeof account.person === 'object') {
|
|
114
114
|
|
|
115
115
|
if (account.org) { helpers.cleanPerson(account.person, account.org); }
|
|
116
116
|
else { account.person.sources = []; }
|
|
@@ -147,7 +147,7 @@ module.exports = function(mongoose, config) {
|
|
|
147
147
|
|
|
148
148
|
_.each(accounts, function(account) {
|
|
149
149
|
|
|
150
|
-
if (account.
|
|
150
|
+
if (account.person && typeof account.person === 'object') {
|
|
151
151
|
|
|
152
152
|
if (account.org) { helpers.cleanPerson(account.person, account.org); }
|
|
153
153
|
else { account.person.sources = []; }
|
|
@@ -176,15 +176,15 @@ module.exports = function(mongoose, config) {
|
|
|
176
176
|
query.populate('org');
|
|
177
177
|
|
|
178
178
|
const account = await query.lean({ virtuals: true });
|
|
179
|
-
if (account && account.
|
|
179
|
+
if (account && account.person && typeof account.person === 'object' && account.org && typeof account.org === 'object') {
|
|
180
180
|
|
|
181
181
|
// Scrub customer info before returning
|
|
182
182
|
|
|
183
|
-
let customerId = account.
|
|
183
|
+
let customerId = account.org._id;
|
|
184
184
|
|
|
185
|
-
if (account.
|
|
185
|
+
if (account.org && typeof account.org === 'object') { helpers.cleanOrg(account.org, customerId); }
|
|
186
186
|
|
|
187
|
-
if (account.
|
|
187
|
+
if (account.person && typeof account.person === 'object') { helpers.cleanPerson(account.person, customerId); }
|
|
188
188
|
|
|
189
189
|
return account;
|
|
190
190
|
|
|
@@ -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
|
-
|
|
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
|
};
|
package/lib/CalendarEvent.js
CHANGED
|
@@ -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
|
-
|
|
507
|
-
|
|
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
|
|
832
|
+
if (typeof deal.markModified === 'function') {
|
|
833
|
+
deal.markModified('customFields');
|
|
834
|
+
}
|
|
833
835
|
|
|
834
|
-
|
|
835
|
-
|
|
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; }
|
package/lib/DiffbotArticle.js
CHANGED
|
@@ -61,9 +61,12 @@ module.exports = function(mongoose, config) {
|
|
|
61
61
|
|
|
62
62
|
const run = async () => {
|
|
63
63
|
doc.updatedOn = new Date();
|
|
64
|
-
doc.
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
279
|
-
|
|
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
|
-
|
|
152
|
-
|
|
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; }
|
package/lib/EventAttendee.js
CHANGED
|
@@ -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
|
-
|
|
138
|
-
|
|
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
|
-
|
|
1234
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
71
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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; }
|
package/lib/Interaction.js
CHANGED
|
@@ -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
|
-
|
|
433
|
-
|
|
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
|
-
|
|
155
|
-
|
|
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; }
|
package/lib/LimitedPartner.js
CHANGED
|
@@ -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
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
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
|
-
|
|
171
|
-
|
|
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
|
-
|
|
264
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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
|
-
|
|
249
|
-
|
|
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
|
-
|
|
182
|
-
|
|
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
|
-
|
|
456
|
-
|
|
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; }
|
package/lib/MessageRecipient.js
CHANGED
|
@@ -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
|
-
|
|
92
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
-
|
|
129
|
-
|
|
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; }
|
package/lib/Organization.js
CHANGED
|
@@ -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
|
-
|
|
2286
|
-
|
|
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
|
-
|
|
1076
|
-
|
|
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
|
-
|
|
56
|
-
|
|
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
|
-
|
|
959
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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; }
|