-
Notifications
You must be signed in to change notification settings - Fork 369
Support for MongoDB $push operator #363
Copy link
Copy link
Open
Labels
Description
I've noticed orm currently only supports the $set operator for MongoDB databases. A simple change to the update method, such as proposed below, would allow other operators such as $push, while maintaining implicit use of $set.
Driver.prototype.update = function (table, changes, conditions, cb) {
convertToDB(changes, this.config.timezone);
convertToDB(conditions, this.config.timezone);
var operator = '$set';
var changesKeys = Object.keys(changes);
if (changesKeys[0][0] == '$') {
operator = changesKeys[0];
changes = changes[operator];
}
var operation = {};
operation[operator] = changes;
return this.db.collection(table).update(
conditions,
operation,
{
safe : true,
upsert : true
},
cb
);
};
Reactions are currently unavailable