fix: mongodb tests

This commit is contained in:
Barış Soner Uşaklı
2019-07-16 00:48:41 -04:00
parent fcf3e0770b
commit 3b24de4cb3

View File

@@ -9,12 +9,13 @@ module.exports = function (db, module) {
module.objectCache = cache;
module.setObject = async function (key, data) {
if (!key || !data) {
const isArray = Array.isArray(key);
if (!key || !data || (isArray && !key.length)) {
return;
}
const writeData = helpers.serializeData(data);
if (Array.isArray(key)) {
if (isArray) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
key.forEach(key => bulk.find({ _key: key }).upsert().updateOne({ $set: writeData }));
await bulk.execute();