Search code examples
meteorminimongo

creating new field for certain records in miniMongo


This Meteor client code tries to create selected fields an sets their values to true, the miniMongo is not being updated.
There are few items in the indexes array. How can it be fixed? Thanks

let res = myColMini.update({
  index: {
    $in: [indexes]
  }
}, {
  $set: {
    selected: true
  }
}, {
  multi: true
});
console.log(res); //<--- 0

Solution

  • Correct, multi is not supported on the client. Either run this update on the server or do:

    myColMini.find({ index: { $in: [indexes] } }).forEach(function(m),{
      myColMini.update(m._id, $set: { selected: true } });
    });