mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: mongodb tests
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user