Skip to content

Instantly share code, notes, and snippets.

@jrgcubano
Last active November 8, 2017 20:20
Show Gist options
  • Save jrgcubano/011b896fee6f434e390d21dc223cdaa9 to your computer and use it in GitHub Desktop.
Save jrgcubano/011b896fee6f434e390d21dc223cdaa9 to your computer and use it in GitHub Desktop.
Mongo collection multiple update with pull test
// candidate a producto
// get elemecodes from candidate
var canditateId = "";
var elemCodes = [ "1", "2", "3"];
// var candidates = monnog.
candidates.update(
{ _id: { $ne: canditateId }, elems: { code: { $in: elemCodes } } },
{ $pull: { elems: { $elemMatch: { code: { $in: elemCodes } } } } } ,
{ multi: true },
function (err) {
if (err) return callback("Error deleting " + err.message);
callback(null, "hello");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment