mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
tests(helpers): Fix local doc update
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable no-use-before-define */
|
/* eslint-disable no-use-before-define */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
assign,
|
set,
|
||||||
each,
|
each,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
times,
|
times,
|
||||||
@@ -282,11 +282,17 @@ function _updateDocument (collectionName, doc, update, cb) {
|
|||||||
|
|
||||||
let collection = db.collection(collectionName);
|
let collection = db.collection(collectionName);
|
||||||
|
|
||||||
collection.update({ _id: doc._id }, { $set: update }, (updateErr) => {
|
collection.updateOne({ _id: doc._id }, { $set: update }, (updateErr) => {
|
||||||
if (updateErr) throw new Error(`Error updating ${collectionName}: ${updateErr}`);
|
if (updateErr) throw new Error(`Error updating ${collectionName}: ${updateErr}`);
|
||||||
assign(doc, update);
|
_updateLocalDocument(doc, update);
|
||||||
db.close();
|
db.close();
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _updateLocalDocument (doc, update) {
|
||||||
|
each(update, (value, param) => {
|
||||||
|
set(doc, param, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user