Update nested array in Meteor

前端 未结 1 1421
别那么骄傲
别那么骄傲 2021-01-26 17:24

This is my schema:

{
_id: \"FJwSEMdDriddXLKXh\"
name: \"t\"
number: \"5\"
owners: [
          {
           _id: 1,
           name: \"Name\",
           address:         


        
相关标签:
1条回答
  • 2021-01-26 17:43

    There is mistake in your query in owners field:

    Territories.update({
             _id: template.data._id,
             owners: {
                 $elemMatch: {
                     _id: this._id
                 }
             },
             {
                 $push: {
                     'owners.$.notes': {
                         title: "First Title"
                     }
                 }
             })
    

    You won't be able to update directly from client side, because you use owners field and only _id is allowed. To solve this you can update using Meteor.methods and call that method from client side.

    0 讨论(0)
提交回复
热议问题