meteor - SimpleSchema invalid keys with nested autoValue -


i have schema (fluff cut out):

schemas.people = new simpleschema({   note: {     type: [schemas.notes],     optional: true,     defaultvalue: []   },   updates: {     type: [schemas.updates],     optional:true,     autovalue:function(){       if (this.isinsert) {         return [{           at: new date,           user_id: this.userid         }];       }        return {         $push:{           at: new date,           user_id: this.userid         }       }     }   } }); 

and notes schema looks like:

schemas.notes = new simpleschema({   note: {     type: string,     autoform: {       affieldinput:{         type:"textarea"       }     },     optional: true   },   updates: {     type: [schemas.updates],     optional:true,     autoform:{       omit:true     },     autovalue:function(){       if (this.isinsert) {         return [{           at: new date,           user_id: this.userid         }];       }        return {         $push:{           at: new date,           user_id: this.userid         }       }     }   } }); 

and updates schema super simple:

schemas.updates = new simpleschema({   at: {     type: date   },   user_id:{     type: meteor.objectid   } }); 

the "updates" field on people schema saves date/user id expected when update made. however, fails on notes schema:

simpleschema invalid keys "blablabla" context: 0: object   name: "note.0.updates.0.at"   type: "keynotinschema"   value: mon may 11 2015 11:57:58 gmt-0400 (eastern daylight time) 1: object   name: "note.0.updates.0.user_id"   type: "keynotinschema"   value: "abcd1234" 

i believe "name" should "people.note.0.updates.0.at" i'm unsure assumption correct , i'm unsure how go making happen.

update:

code used update people

  {{#autoform collection="people" id=formid type="update" class="update" autocomplete="off" doc=getdocument autosave=true template="quickform"}}   {{> afquickfield name='note' template="quickform" }}   {{/autoform}} 

formid returns randomish id string , getdocument passes in correct collection.

schemas.notes._schemakeys not list at , user_id fields... schemas.people._schemakeys does.

people schema shows: [..., "updates.$.at", "updates.$.user_id", ...]

notes schema shows: ["note", "updates", "updates.$"]

how bizarre.

note meteor uses standard javascript syntax , therefore has same restrictions, example realized order of code important.

let's have look.

schemas.notes = new simpleschema({   updates: {     type: [schemas.updates]   } } 

there no nested functions in code, therefore every code of line executed, before meteor continues next schema definition. schema.updates dereferenced immediately, although isn't set yet. type array containing null , makes simpleschema assume no fields allowed @ all.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -