@dhyasama/totem-merge 6.20.0 → 7.0.1
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/cli.js +5 -8
- package/lib/helpers.js +1 -1
- package/lib/organizations.js +32 -42
- package/lib/people.js +29 -38
- package/package.json +9 -4
- package/test/index.js +5 -7
package/cli.js
CHANGED
|
@@ -14,17 +14,14 @@ mongoose.connection.on('error', function(err) {
|
|
|
14
14
|
done(err);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
mongoose.connect(config.db.uri
|
|
17
|
+
mongoose.connect(config.db.uri).then(function() {
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
else {
|
|
19
|
+
console.log('Connected to ' + config.db.uri.substring(config.db.uri.indexOf('@') + 1) + '\n');
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
buildProgram();
|
|
25
|
-
|
|
26
|
-
}
|
|
21
|
+
buildProgram();
|
|
27
22
|
|
|
23
|
+
}).catch(function(err) {
|
|
24
|
+
done(err);
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
// npm start p 5637a8c0281347cc0bbfca30 5637a8c0281347cc0bbfca3e jason
|
package/lib/helpers.js
CHANGED
|
@@ -74,7 +74,7 @@ var removeEntity = module.exports.removeEntity = function removeEntity(context,
|
|
|
74
74
|
|
|
75
75
|
context.logger.writeToInfoLog('Removing entity - ' + entity._id.toString());
|
|
76
76
|
|
|
77
|
-
entity.
|
|
77
|
+
entity.deleteOne().then(function() { cb(null, entity); }).catch(cb);
|
|
78
78
|
|
|
79
79
|
};
|
|
80
80
|
|
package/lib/organizations.js
CHANGED
|
@@ -159,8 +159,8 @@ var updateReferences = function updateReferences(context, target, source, merged
|
|
|
159
159
|
if (!source) return cb(new Error('source is required'), null);
|
|
160
160
|
if (!cb) throw new Error('cb is required');
|
|
161
161
|
|
|
162
|
-
var oldOrgId = ObjectId(source.id);
|
|
163
|
-
var newOrgId = ObjectId(target.id);
|
|
162
|
+
var oldOrgId = new ObjectId(source.id);
|
|
163
|
+
var newOrgId = new ObjectId(target.id);
|
|
164
164
|
|
|
165
165
|
logger.writeToInfoLog(' Target: ' + newOrgId.toString());
|
|
166
166
|
logger.writeToInfoLog(' Source: ' + oldOrgId.toString());
|
|
@@ -190,10 +190,9 @@ var updateCapTables = function updateCapTables(newOrgId, oldOrgId, cb) {
|
|
|
190
190
|
var self = this;
|
|
191
191
|
|
|
192
192
|
// Get all cap tables for this org
|
|
193
|
-
self.CapTable.collection.find({ 'organization': oldOrgId }).toArray(function(
|
|
193
|
+
self.CapTable.collection.find({ 'organization': oldOrgId }).toArray().then(function(items) {
|
|
194
194
|
|
|
195
|
-
if (
|
|
196
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
195
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
197
196
|
|
|
198
197
|
var tasks = [];
|
|
199
198
|
var updated = [];
|
|
@@ -209,18 +208,17 @@ var updateCapTables = function updateCapTables(newOrgId, oldOrgId, cb) {
|
|
|
209
208
|
|
|
210
209
|
var queue = async.queue(function(task, callback) {
|
|
211
210
|
|
|
212
|
-
self.CapTable.collection.updateOne({ _id: task.id }, task.update
|
|
213
|
-
if (
|
|
214
|
-
else if (result) { updated.push(result); }
|
|
211
|
+
self.CapTable.collection.updateOne({ _id: task.id }, task.update).then(function(result) {
|
|
212
|
+
if (result) { updated.push(result); }
|
|
215
213
|
return callback(null, result);
|
|
216
|
-
});
|
|
214
|
+
}, function(err) { return callback(err, null); });
|
|
217
215
|
}, 8);
|
|
218
216
|
|
|
219
217
|
queue.drain = function() { return cb(null, updated); };
|
|
220
218
|
|
|
221
219
|
queue.push(tasks);
|
|
222
220
|
|
|
223
|
-
});
|
|
221
|
+
}).catch(function(err) { cb(err, null); });
|
|
224
222
|
|
|
225
223
|
};
|
|
226
224
|
|
|
@@ -231,10 +229,9 @@ var updateDeals = function updateDeals(newOrgId, oldOrgId, customerId, cb) {
|
|
|
231
229
|
var self = this;
|
|
232
230
|
|
|
233
231
|
// Get all deals for this org
|
|
234
|
-
self.Deal.collection.find({ 'organization': oldOrgId }).toArray(function(
|
|
232
|
+
self.Deal.collection.find({ 'organization': oldOrgId }).toArray().then(function(items) {
|
|
235
233
|
|
|
236
|
-
if (
|
|
237
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
234
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
238
235
|
|
|
239
236
|
var tasks = [];
|
|
240
237
|
var updated = [];
|
|
@@ -261,7 +258,7 @@ var updateDeals = function updateDeals(newOrgId, oldOrgId, customerId, cb) {
|
|
|
261
258
|
|
|
262
259
|
queue.push(tasks);
|
|
263
260
|
|
|
264
|
-
});
|
|
261
|
+
}).catch(function(err) { cb(err, null); });
|
|
265
262
|
|
|
266
263
|
};
|
|
267
264
|
|
|
@@ -272,10 +269,9 @@ var updateFinancials = function updateFinancials(newOrgId, oldOrgId, cb) {
|
|
|
272
269
|
var self = this;
|
|
273
270
|
|
|
274
271
|
// Get all financials for this org
|
|
275
|
-
self.Financials.collection.find({ 'organization': oldOrgId }).toArray(function(
|
|
272
|
+
self.Financials.collection.find({ 'organization': oldOrgId }).toArray().then(function(items) {
|
|
276
273
|
|
|
277
|
-
if (
|
|
278
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
274
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
279
275
|
|
|
280
276
|
var tasks = [];
|
|
281
277
|
var updated = [];
|
|
@@ -291,18 +287,17 @@ var updateFinancials = function updateFinancials(newOrgId, oldOrgId, cb) {
|
|
|
291
287
|
|
|
292
288
|
var queue = async.queue(function(task, callback) {
|
|
293
289
|
|
|
294
|
-
self.Financials.collection.updateOne({ _id: task.id }, task.update
|
|
295
|
-
if (
|
|
296
|
-
else if (result) { updated.push(result); }
|
|
290
|
+
self.Financials.collection.updateOne({ _id: task.id }, task.update).then(function(result) {
|
|
291
|
+
if (result) { updated.push(result); }
|
|
297
292
|
return callback(null, result);
|
|
298
|
-
});
|
|
293
|
+
}, function(err) { return callback(err, null); });
|
|
299
294
|
}, 8);
|
|
300
295
|
|
|
301
296
|
queue.drain = function() { return cb(null, updated); };
|
|
302
297
|
|
|
303
298
|
queue.push(tasks);
|
|
304
299
|
|
|
305
|
-
});
|
|
300
|
+
}).catch(function(err) { cb(err, null); });
|
|
306
301
|
|
|
307
302
|
};
|
|
308
303
|
|
|
@@ -312,10 +307,9 @@ var updateMessages = function updateMessages(newOrgId, oldOrgId, cb) {
|
|
|
312
307
|
|
|
313
308
|
var self = this;
|
|
314
309
|
|
|
315
|
-
self.Message.collection.find({ 'organization': oldOrgId }).toArray(function(
|
|
310
|
+
self.Message.collection.find({ 'organization': oldOrgId }).toArray().then(function(items) {
|
|
316
311
|
|
|
317
|
-
if (
|
|
318
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
312
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
319
313
|
|
|
320
314
|
var tasks = [];
|
|
321
315
|
var updated = [];
|
|
@@ -341,7 +335,7 @@ var updateMessages = function updateMessages(newOrgId, oldOrgId, cb) {
|
|
|
341
335
|
|
|
342
336
|
queue.push(tasks);
|
|
343
337
|
|
|
344
|
-
});
|
|
338
|
+
}).catch(function(err) { cb(err, null); });
|
|
345
339
|
|
|
346
340
|
};
|
|
347
341
|
|
|
@@ -351,10 +345,9 @@ var updateNews = function updateNews(newOrgId, oldOrgId, cb) {
|
|
|
351
345
|
|
|
352
346
|
var self = this;
|
|
353
347
|
|
|
354
|
-
self.News.collection.find({ 'org': oldOrgId }).toArray(function(
|
|
348
|
+
self.News.collection.find({ 'org': oldOrgId }).toArray().then(function(items) {
|
|
355
349
|
|
|
356
|
-
if (
|
|
357
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
350
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
358
351
|
|
|
359
352
|
var tasks = [];
|
|
360
353
|
var updated = [];
|
|
@@ -380,7 +373,7 @@ var updateNews = function updateNews(newOrgId, oldOrgId, cb) {
|
|
|
380
373
|
|
|
381
374
|
queue.push(tasks);
|
|
382
375
|
|
|
383
|
-
});
|
|
376
|
+
}).catch(function(err) { cb(err, null); });
|
|
384
377
|
|
|
385
378
|
};
|
|
386
379
|
|
|
@@ -390,10 +383,9 @@ var updateOrganizations = function updateOrganizations(newOrgId, oldOrgId, cb) {
|
|
|
390
383
|
|
|
391
384
|
var self = this;
|
|
392
385
|
|
|
393
|
-
self.Organization.collection.find({ $or: [{ 'merged': oldOrgId }, { 'operating.acquired.public.by': oldOrgId }, { 'operating.acquired.private.by': oldOrgId }, { 'related': oldOrgId }] }).toArray(function(
|
|
386
|
+
self.Organization.collection.find({ $or: [{ 'merged': oldOrgId }, { 'operating.acquired.public.by': oldOrgId }, { 'operating.acquired.private.by': oldOrgId }, { 'related': oldOrgId }] }).toArray().then(function(items) {
|
|
394
387
|
|
|
395
|
-
if (
|
|
396
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
388
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
397
389
|
|
|
398
390
|
var tasks = [];
|
|
399
391
|
var updated = [];
|
|
@@ -441,7 +433,7 @@ var updateOrganizations = function updateOrganizations(newOrgId, oldOrgId, cb) {
|
|
|
441
433
|
|
|
442
434
|
queue.push(tasks);
|
|
443
435
|
|
|
444
|
-
});
|
|
436
|
+
}).catch(function(err) { cb(err, null); });
|
|
445
437
|
|
|
446
438
|
};
|
|
447
439
|
|
|
@@ -452,10 +444,9 @@ var updateRounds = function updateRounds(newOrgId, oldOrgId, cb) {
|
|
|
452
444
|
var self = this;
|
|
453
445
|
|
|
454
446
|
// Get all rounds for this org
|
|
455
|
-
self.Round.collection.find({ 'organization': oldOrgId }).toArray(function(
|
|
447
|
+
self.Round.collection.find({ 'organization': oldOrgId }).toArray().then(function(items) {
|
|
456
448
|
|
|
457
|
-
if (
|
|
458
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
449
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
459
450
|
|
|
460
451
|
var tasks = [];
|
|
461
452
|
var updated = [];
|
|
@@ -471,18 +462,17 @@ var updateRounds = function updateRounds(newOrgId, oldOrgId, cb) {
|
|
|
471
462
|
|
|
472
463
|
var queue = async.queue(function(task, callback) {
|
|
473
464
|
|
|
474
|
-
self.Round.collection.updateOne({ _id: task.id }, task.update
|
|
475
|
-
if (
|
|
476
|
-
else if (result) { updated.push(result); }
|
|
465
|
+
self.Round.collection.updateOne({ _id: task.id }, task.update).then(function(result) {
|
|
466
|
+
if (result) { updated.push(result); }
|
|
477
467
|
return callback(null, result);
|
|
478
|
-
});
|
|
468
|
+
}, function(err) { return callback(err, null); });
|
|
479
469
|
}, 8);
|
|
480
470
|
|
|
481
471
|
queue.drain = function() { return cb(null, updated); };
|
|
482
472
|
|
|
483
473
|
queue.push(tasks);
|
|
484
474
|
|
|
485
|
-
});
|
|
475
|
+
}).catch(function(err) { cb(err, null); });
|
|
486
476
|
|
|
487
477
|
};
|
|
488
478
|
|
package/lib/people.js
CHANGED
|
@@ -151,8 +151,8 @@ var updateReferences = function updateReferences(context, target, source, merged
|
|
|
151
151
|
if (!source) return cb(new Error('source is required'), null);
|
|
152
152
|
if (!cb) throw new Error('cb is required');
|
|
153
153
|
|
|
154
|
-
var oldPersonId = ObjectId(source.id);
|
|
155
|
-
var newPersonId = ObjectId(target.id);
|
|
154
|
+
var oldPersonId = new ObjectId(source.id);
|
|
155
|
+
var newPersonId = new ObjectId(target.id);
|
|
156
156
|
|
|
157
157
|
console.log(' Target:', newPersonId.toString());
|
|
158
158
|
console.log(' Source:', oldPersonId.toString());
|
|
@@ -192,10 +192,9 @@ var updateDeals = function updateDeals(newPersonId, oldPersonId, user, cb) {
|
|
|
192
192
|
var self = this;
|
|
193
193
|
|
|
194
194
|
// Get all deals for this person
|
|
195
|
-
self.Deal.collection.find({ $or: [{ 'source.person': oldPersonId }, { 'referrer.person': oldPersonId }]}).toArray(function(
|
|
195
|
+
self.Deal.collection.find({ $or: [{ 'source.person': oldPersonId }, { 'referrer.person': oldPersonId }]}).toArray().then(function(items) {
|
|
196
196
|
|
|
197
|
-
if (
|
|
198
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
197
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
199
198
|
|
|
200
199
|
var tasks = [];
|
|
201
200
|
var updated = [];
|
|
@@ -228,7 +227,7 @@ var updateDeals = function updateDeals(newPersonId, oldPersonId, user, cb) {
|
|
|
228
227
|
|
|
229
228
|
queue.push(tasks);
|
|
230
229
|
|
|
231
|
-
});
|
|
230
|
+
}).catch(function(err) { cb(err, null); });
|
|
232
231
|
|
|
233
232
|
};
|
|
234
233
|
|
|
@@ -241,10 +240,9 @@ var updateDocuments = function updateDocuments(newPersonId, oldPersonId, user, c
|
|
|
241
240
|
if (!self.Document || !self.Document.collection) { return cb(null, []); }
|
|
242
241
|
|
|
243
242
|
// Get all documents created by this person
|
|
244
|
-
self.Document.collection.find({ 'createdBy': oldPersonId }).toArray(function(
|
|
243
|
+
self.Document.collection.find({ 'createdBy': oldPersonId }).toArray().then(function(items) {
|
|
245
244
|
|
|
246
|
-
if (
|
|
247
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
245
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
248
246
|
|
|
249
247
|
var tasks = [];
|
|
250
248
|
var updated = [];
|
|
@@ -278,7 +276,7 @@ var updateDocuments = function updateDocuments(newPersonId, oldPersonId, user, c
|
|
|
278
276
|
|
|
279
277
|
queue.push(tasks);
|
|
280
278
|
|
|
281
|
-
});
|
|
279
|
+
}).catch(function(err) { cb(err, null); });
|
|
282
280
|
|
|
283
281
|
};
|
|
284
282
|
|
|
@@ -293,10 +291,9 @@ var updateMeetings = function updateMeetings(newPersonId, oldPersonId, user, cb)
|
|
|
293
291
|
}
|
|
294
292
|
|
|
295
293
|
// Get all meetings containing the old person id in people array
|
|
296
|
-
self.Meeting.collection.find({ 'people': oldPersonId }).toArray(function(
|
|
294
|
+
self.Meeting.collection.find({ 'people': oldPersonId }).toArray().then(function(items) {
|
|
297
295
|
|
|
298
|
-
if (
|
|
299
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
296
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
300
297
|
|
|
301
298
|
var tasks = [];
|
|
302
299
|
var updated = [];
|
|
@@ -318,18 +315,17 @@ var updateMeetings = function updateMeetings(newPersonId, oldPersonId, user, cb)
|
|
|
318
315
|
console.log(' Found ' + tasks.length + ' meeting references to update');
|
|
319
316
|
|
|
320
317
|
var queue = async.queue(function(task, callback) {
|
|
321
|
-
self.Meeting.findByIdAndUpdate(task.id, task.update, { upsert: false, new: true }
|
|
322
|
-
if (
|
|
323
|
-
else if (result) { updated.push(result); }
|
|
318
|
+
self.Meeting.findByIdAndUpdate(task.id, task.update, { upsert: false, new: true }).then(function(result) {
|
|
319
|
+
if (result) { updated.push(result); }
|
|
324
320
|
return callback(null, result);
|
|
325
|
-
});
|
|
321
|
+
}, function(err) { return callback(err, null); });
|
|
326
322
|
}, 8);
|
|
327
323
|
|
|
328
324
|
queue.drain = function() { return cb(null, updated); };
|
|
329
325
|
|
|
330
326
|
queue.push(tasks);
|
|
331
327
|
|
|
332
|
-
});
|
|
328
|
+
}).catch(function(err) { cb(err, null); });
|
|
333
329
|
|
|
334
330
|
};
|
|
335
331
|
|
|
@@ -340,10 +336,9 @@ var updateLimitedPartners = function updateLimitedPartners(newPersonId, oldPerso
|
|
|
340
336
|
var self = this;
|
|
341
337
|
|
|
342
338
|
// Get all lps for this person
|
|
343
|
-
self.LimitedPartner.collection.find({ 'people': oldPersonId }).toArray(function(
|
|
339
|
+
self.LimitedPartner.collection.find({ 'people': oldPersonId }).toArray().then(function(items) {
|
|
344
340
|
|
|
345
|
-
if (
|
|
346
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
341
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
347
342
|
|
|
348
343
|
var tasks = [];
|
|
349
344
|
var updated = [];
|
|
@@ -379,7 +374,7 @@ var updateLimitedPartners = function updateLimitedPartners(newPersonId, oldPerso
|
|
|
379
374
|
|
|
380
375
|
queue.push(tasks);
|
|
381
376
|
|
|
382
|
-
});
|
|
377
|
+
}).catch(function(err) { cb(err, null); });
|
|
383
378
|
|
|
384
379
|
};
|
|
385
380
|
|
|
@@ -390,10 +385,9 @@ var updateMessages = function updateMessages(newPersonId, oldPersonId, user, cb)
|
|
|
390
385
|
var self = this;
|
|
391
386
|
|
|
392
387
|
// Get all messages for this person
|
|
393
|
-
self.Message.collection.find({ $or: [{ 'recipients.external': oldPersonId }, { 'recipients.internal': oldPersonId }] }).toArray(function(
|
|
388
|
+
self.Message.collection.find({ $or: [{ 'recipients.external': oldPersonId }, { 'recipients.internal': oldPersonId }] }).toArray().then(function(items) {
|
|
394
389
|
|
|
395
|
-
if (
|
|
396
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
390
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
397
391
|
|
|
398
392
|
var tasks = [];
|
|
399
393
|
var updated = [];
|
|
@@ -435,7 +429,7 @@ var updateMessages = function updateMessages(newPersonId, oldPersonId, user, cb)
|
|
|
435
429
|
|
|
436
430
|
queue.push(tasks);
|
|
437
431
|
|
|
438
|
-
});
|
|
432
|
+
}).catch(function(err) { cb(err, null); });
|
|
439
433
|
|
|
440
434
|
};
|
|
441
435
|
|
|
@@ -446,10 +440,9 @@ var updateNotes = function updateNotes(newPersonId, oldPersonId, user, cb) {
|
|
|
446
440
|
var self = this;
|
|
447
441
|
|
|
448
442
|
// Get all notes for this person
|
|
449
|
-
self.Note.collection.find({ 'createdBy': oldPersonId }).toArray(function(
|
|
443
|
+
self.Note.collection.find({ 'createdBy': oldPersonId }).toArray().then(function(items) {
|
|
450
444
|
|
|
451
|
-
if (
|
|
452
|
-
else if (!items || items.length === 0) return cb(null, []);
|
|
445
|
+
if (!items || items.length === 0) return cb(null, []);
|
|
453
446
|
|
|
454
447
|
var tasks = [];
|
|
455
448
|
var updated = [];
|
|
@@ -481,7 +474,7 @@ var updateNotes = function updateNotes(newPersonId, oldPersonId, user, cb) {
|
|
|
481
474
|
|
|
482
475
|
queue.push(tasks);
|
|
483
476
|
|
|
484
|
-
});
|
|
477
|
+
}).catch(function(err) { cb(err, null); });
|
|
485
478
|
|
|
486
479
|
};
|
|
487
480
|
|
|
@@ -492,10 +485,9 @@ var updateOrganizations = function updateOrganizations(newPersonId, oldPersonId,
|
|
|
492
485
|
var self = this;
|
|
493
486
|
|
|
494
487
|
// Get all orgs for this person
|
|
495
|
-
self.Organization.collection.find({ $or: [{ 'people.person': oldPersonId }, { 'chairs.first': oldPersonId }, { 'chairs.second': oldPersonId }] }).toArray(function(
|
|
488
|
+
self.Organization.collection.find({ $or: [{ 'people.person': oldPersonId }, { 'chairs.first': oldPersonId }, { 'chairs.second': oldPersonId }] }).toArray().then(function(orgs) {
|
|
496
489
|
|
|
497
|
-
if (
|
|
498
|
-
else if (!orgs || orgs.length === 0) return cb(null, []);
|
|
490
|
+
if (!orgs || orgs.length === 0) return cb(null, []);
|
|
499
491
|
|
|
500
492
|
var tasks = [];
|
|
501
493
|
var updated = [];
|
|
@@ -579,7 +571,7 @@ var updateOrganizations = function updateOrganizations(newPersonId, oldPersonId,
|
|
|
579
571
|
|
|
580
572
|
queue.push(tasks);
|
|
581
573
|
|
|
582
|
-
});
|
|
574
|
+
}).catch(function(err) { cb(err, null); });
|
|
583
575
|
|
|
584
576
|
};
|
|
585
577
|
|
|
@@ -590,10 +582,9 @@ var updatePeople = function updatePeople(newPersonId, oldPersonId, user, cb) {
|
|
|
590
582
|
var self = this;
|
|
591
583
|
|
|
592
584
|
// Update Person.related where oldPersonId appears
|
|
593
|
-
self.Person.collection.find({ 'related': oldPersonId }).toArray(function(
|
|
585
|
+
self.Person.collection.find({ 'related': oldPersonId }).toArray().then(function(people) {
|
|
594
586
|
|
|
595
|
-
if (
|
|
596
|
-
else if (!people || people.length === 0) return cb(null, []);
|
|
587
|
+
if (!people || people.length === 0) return cb(null, []);
|
|
597
588
|
|
|
598
589
|
var tasks = [];
|
|
599
590
|
var updated = [];
|
|
@@ -628,7 +619,7 @@ var updatePeople = function updatePeople(newPersonId, oldPersonId, user, cb) {
|
|
|
628
619
|
|
|
629
620
|
queue.push(tasks);
|
|
630
621
|
|
|
631
|
-
});
|
|
622
|
+
}).catch(function(err) { cb(err, null); });
|
|
632
623
|
|
|
633
624
|
};
|
|
634
625
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhyasama/totem-merge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Org and person merging package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,17 +12,22 @@
|
|
|
12
12
|
"registry": "https://registry.npmjs.org/"
|
|
13
13
|
},
|
|
14
14
|
"author": "Jason Reynolds",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=24 <25"
|
|
17
|
+
},
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"@dhyasama/totem-logger": "^2.1.0",
|
|
17
|
-
"@dhyasama/totem-utilities": "^
|
|
20
|
+
"@dhyasama/totem-utilities": "^4.0.0",
|
|
18
21
|
"async": "^2.6.4",
|
|
19
22
|
"commander": "^2.20.3",
|
|
20
|
-
"mongoose": "~4.5.7",
|
|
21
23
|
"phone-formatter": "0.0.2",
|
|
22
24
|
"underscore": "^1.13.6"
|
|
23
25
|
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"mongoose": "^8.23.0"
|
|
28
|
+
},
|
|
24
29
|
"devDependencies": {
|
|
25
|
-
"@dhyasama/totem-models": "^
|
|
30
|
+
"@dhyasama/totem-models": "^12.14.0",
|
|
26
31
|
"mocha": "^5.2.0",
|
|
27
32
|
"mocha-mongoose": "^1.1.1",
|
|
28
33
|
"should": "^8.2.2"
|
package/test/index.js
CHANGED
|
@@ -29,9 +29,9 @@ var person1, person2, person3;
|
|
|
29
29
|
describe('Merge', function() {
|
|
30
30
|
|
|
31
31
|
// connect to test db
|
|
32
|
-
before(function(
|
|
33
|
-
if (mongoose.connection.db) return
|
|
34
|
-
mongoose.connect(config.db.uri
|
|
32
|
+
before(async function() {
|
|
33
|
+
if (mongoose.connection.db) return;
|
|
34
|
+
await mongoose.connect(config.db.uri);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
// clear test db
|
|
@@ -631,16 +631,14 @@ describe('Merge', function() {
|
|
|
631
631
|
|
|
632
632
|
org6 = result2;
|
|
633
633
|
|
|
634
|
-
News.findById(news.id
|
|
635
|
-
|
|
636
|
-
should.not.exist(err);
|
|
634
|
+
News.findById(news.id).exec().then(function(result3) {
|
|
637
635
|
should.exist(result3);
|
|
638
636
|
|
|
639
637
|
result3.org.toString().should.equal(org6._id.toString());
|
|
640
638
|
|
|
641
639
|
return done();
|
|
642
640
|
|
|
643
|
-
});
|
|
641
|
+
}).catch(done);
|
|
644
642
|
|
|
645
643
|
});
|
|
646
644
|
|