meteor - Accessing nested array in autoform hook -


i have collection looks this:

 "request":{   type: [object],   optional: true,   autovalue: function() {                 var input = this.field('requestinput');     var type = this.field('requesttypeinput');     var emailto = this.field('emailtoinput');     var direction = this.field('directioninput');     var d = new date;     //var requestfiles = this.field('requestfiles');        //console.log(requestfiles.value);     if(!!input.value){       if(this.isinsert){           return [{             "_id":random.id(),             date: new date(),             type: type.value,             details: input.value,             emailto: emailto.value,             direction : direction.value,            // requestfiles: requestfiles.value,             createdby: this.userid         }];        } else {            return {            $push: {                "_id":random.id(),               date: new date(),               type: type.value,               details: input.value,               emailto: emailto.value,               direction : direction.value,              // requestfiles: requestfiles.value,               createdby: this.userid            }          };       }     } else {      this.unset();    }  } }, 'request.$.date': { type: date, optional: true }, 'request.$.details': { type: string, optional: true }, 'request.$.createdby':{   type: string,   optional: true }, "request.$.type":{  type: string }, "request.$._id":{  type: string }, "request.$.emailto":{  type: string,  max: 1000,  optional: true   }, "request.$.direction":{  type: string,  max: 1000,  optional: true }, "request.$.requestfiles":{  type: [string],  optional: true } 

what want use before hook set value of requestfiles cannot access it. have far:

 before:{       "method-update": function(doc) {       doc.$set.request.requestfiles = arrayoffiles.list();       return doc;       } } 

this telling me :

 uncaught typeerror: cannot set property 'requestfiles' of undefined. 

i have tried:

doc.$set.request.0.requestfiles = arrayoffiles.list(); doc.$set.request[0].requestfiles = arrayoffiles.list(); 

i want pass array value. if there solution passing value accept it.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -