Skip to content

Node.js based forum software built for the modern web

fix: mongodb tests

Barış Soner Uşaklı3b24de4cb30b
diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js
index cacde06614..f10ac08e63 100644
--- a/src/database/mongo/hash.js
+++ b/src/database/mongo/hash.js
@@ -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();