meteor - MongoDB updating field contained in subdocument throws an error -
my collection schema looks this:
products :{ _id: "s2of6hitskzwy5toz", user_id: "lkahkhk5svtr6r8sk", shop: "ebay.com", items: { item: "hp laptop" item_total: 101.67 notes: "note hp laptop" price: 101.67 quantity: 1 shop: "ebay.com" url: "ebay.com/hp" }, expenses: { bank_fee: 0 cod_fee: 0 expense_total: 0 inbound_fee: 0 pcs_fee: 0 pjp_fee: 0 }, service_fee: 15.25, total: 116.92 }
i want update bank_fee
field in expenses
subdocument using update
query using syntax:
insertfee : function(user_id, id, fee_amount){ products.update({user_id: user_id, _id: id}, {$set: {"expenses.$.bank_fee":fee_amount}}); }
however throws error:
exception while invoking method 'insertfee' mongoerror: can't append array ing string field name [$]
what doing wrong here?
p.s. following this doc update operation.
Comments
Post a Comment