I am trying to get the value of a nested array from a method that updates an Autoform generated form.
I have a schema set up like this...
Schema.ContactDetails = new SimpleSchema({
orderedBy: {
type: String,
label: "Ordered By",
optional: true,
},
[...]
)};
Orders.attachSchema(new SimpleSchema({
[...]
orderDetails: {
type: Schema.OrderDetails,
optional: true,
blackbox: true
},
[...]
)};
I then have an Autoform set up with this...
{{#autoForm collection="Orders" id="updateOrderForm" type="method-update" meteormethod="updateOrder" doc=this}}
[...]
{{/autoForm}}
And this is the updateOrder method...
updateOrder: function (doc,doc_id) {
check(doc, Orders.simpleSchema());
console.log(doc);
//Modify doc here
Orders.update({_id: doc_id}, doc);
},
The above console.log(doc);
outputs the following...
{ '$set':
{ createdBy: 'o5Wye6LLMGNXLn7HY',
createdAt: Sat Apr 09 2016 22:15:27 GMT+1000 (AEST),
'contactDetails.orderedBy': 'MvCun8p6vxndj3cr8',
updatedAt: Mon Apr 11 2016 11:47:31 GMT+1000 (AEST) },
'$unset':
{ […]
My problem is that I need to get the 'contactDetails.orderedBy' value in the updateOrder method but I can't seem to access it. I have tried the following...
var orderedBy = doc.$set.contactDetails.orderedBy;
Exception while invoking method 'updateOrder' TypeError: Cannot read property 'orderedBy' of undefined
var orderedBy = doc.$set.'contactDetails.orderedBy';
Unexpected token error
Thanks in advance