mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: mongodb tests
This commit is contained in:
@@ -9,12 +9,13 @@ module.exports = function (db, module) {
|
|||||||
module.objectCache = cache;
|
module.objectCache = cache;
|
||||||
|
|
||||||
module.setObject = async function (key, data) {
|
module.setObject = async function (key, data) {
|
||||||
if (!key || !data) {
|
const isArray = Array.isArray(key);
|
||||||
|
if (!key || !data || (isArray && !key.length)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeData = helpers.serializeData(data);
|
const writeData = helpers.serializeData(data);
|
||||||
if (Array.isArray(key)) {
|
if (isArray) {
|
||||||
var bulk = db.collection('objects').initializeUnorderedBulkOp();
|
var bulk = db.collection('objects').initializeUnorderedBulkOp();
|
||||||
key.forEach(key => bulk.find({ _key: key }).upsert().updateOne({ $set: writeData }));
|
key.forEach(key => bulk.find({ _key: key }).upsert().updateOne({ $set: writeData }));
|
||||||
await bulk.execute();
|
await bulk.execute();
|
||||||
|
|||||||
Reference in New Issue
Block a user