How do I go about updating the values of an embedded object within a mongoDB document?
The values displayed for {{service.id}} and {{service.username}} in the table template are correct. However, I am unsure of the correct way to access them within the saveItem()
function. When attempting service.id
, service.$.id
, and service.[0].id
, I encounter an Error: Unexpected token .
. Similarly, using "service.id"
results in a submission with no outcome, while "service.[0].id"
gets the form stuck in edit mode. Lastly, "service.$.id"
throws an error indicating that the $ field is not updateable.
Could there be something missing in my JavaScript code, or am I possibly mishandling the schema definition (i.e., unnecessary use of dollar signs)?
Thank you!
Here is the code snippet:
var Schemas = {};
Items = new Meteor.Collection('items');
Schemas.Items = new SimpleSchema({
_id: {
type: String,
},
name: {
type: String,
label: "Item Name",
min: 1
},
"service.$": {
type: [Object]
},
"service.$.id": {
type: Number
},
"service.$.username": {
type: String
}
});
Items.attachSchema(Schemas.Items);
...