Updating Minimongo subdocument Array


I need some clarity has to why/how to update Minimongo subdocument array object value.

Tried doing the following but I received the error below. What is the best approach for this?

 data: {
   _id: "DrzG9Du5rZes2bfQg"
   creationDate: Tue Nov 17 2015 22:04:53 GMT-0700 (US Mountain Standard Time)
      listItems: [{
         creationDate: Tue Nov 17 2015 22:05:11 GMT-0700 (US Mountain Standard Time)
         isDone: false
         isle: "1"
         itemName: "Lobster"
         num: 0
         quantity: "1"

 'click #isDone': function (e, tmpl) {
    let setData = {};

    const index = tmpl.$('input').index();

    const itemTarget = 'tmpl.data.listItems.' + index + '.isDone';

    setData[itemTarget] = tmpl.$('#isDone').checked;
        _id: tmpl.data._id
    }, {
        $set : setData

update failed: MongoError: ‘$set’ is empty. You must specify a field like so: {$mod: {: …}}



u forgot listItems in update argument :smiley:
and if you are not going to replace whole array with new one, you need to use classic array functions, consult mongodb manual.


@shock setData object takes care of that.


I use autoform for editing arrays, but if you want to code it yourself here you go https://docs.mongodb.org/v3.0/reference/operator/update-array/

PS; I am not sure how is $ supported in minimongo, but it should not be hard to check it in browser console


Now when I am looking on your script it should work, are you sure the setData object is filled correctly with values?
console.log it or console.log JSON.stringify of it and paste here.