Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
hemera.add(StorePattern.replace(topic), function(req, cb) {
const collection = db.collection(req.collection)
const store = new MongoStore(collection, opts)
store.ObjectID = ObjectID
req.query = deserialize(req.query)
store.replace(req, deserialize(req.data), cb)
})
hemera.add(StorePattern.updateById(topic), function(req, cb) {
const collection = db.collection(req.collection)
const store = new MongoStore(collection, opts)
store.ObjectID = ObjectID
store.updateById(req, deserialize(req.data), (err, result) => {
if (err) {
cb(err)
} else {
cb(null, preResponseHandler(result))
}
})
})
hemera.add(StorePattern.update(topic), function(req, cb) {
const collection = db.collection(req.collection)
const store = new MongoStore(collection, opts)
store.ObjectID = ObjectID
req.query = deserialize(req.query)
store.update(req, deserialize(req.data), (err, result) => {
if (err) {
cb(err)
} else {
cb(null, preResponseHandler(result))
}
})
})
hemera.add(StorePattern.create(topic), function(req, cb) {
const collection = db.collection(req.collection)
const store = new MongoStore(collection, opts)
store.ObjectID = ObjectID
req.data = deserialize(req.data)
store.create(req, cb)
})
hemera.add(StorePattern.update(topic), function(req, cb) {
const collection = db.collection(req.collection)
const store = new MongoStore(collection, opts)
store.ObjectID = ObjectID
req.query = deserialize(req.query)
store.update(req, deserialize(req.data), (err, result) => {
if (err) {
cb(err)
} else {
cb(null, preResponseHandler(result))
}
})
})
let promises = [];
for (const collection in data) {
let docs = data[collection];
if (docs.length === 0) {
continue;
}
for (let i = 0; i < docs.length; ++i) {
const doc = docs[i];
expand(extensions, doc);
const tmp = doc.$set;
delete doc.$set;
for (const key in tmp) {
dot.set(doc, key, tmp[key]);
}
docs[i] = ejson.deserialize(doc);
}
promises.push(db.collection(collection).insert(docs));
}
if (get(options, 'clearConnection', null)) {
yield db.close();
}
const res = yield promises;
return res;
});
}
hemera.add(StorePattern.replaceById(topic), function(req, cb) {
const collection = db.collection(req.collection)
const store = new MongoStore(collection, opts)
store.ObjectID = ObjectID
store.replaceById(req, deserialize(req.data), (err, result) => {
if (err) {
cb(err)
} else {
cb(null, preResponseHandler(result))
}
})
})