Simple Schema populate default value from collection -
how possible populate simple schema's default value call collection in meteor js instead of defining "tests" within defaultvalue below? if possible have defaultvalue return testlist = new mongo.collection('testlist').
studentschema = new simpleschema({ tests: { type: [object], blackbox: true, optional: true, defaultvalue:[ { "_id" : "t2yfqwj3a5rqz64wn", "category_id" : "5", "active" : "true", "category" : "cognitive/intelligence", "abbr" : "wj-iv cog", "name" : "woodcock-johnson iv, tests of cognitive abilities", "publisher" : "riverside publishing" }, { "_id" : "ai8bt6dlygqrdfvke", "category_id" : "5", "active" : "true", "category" : "cognitive/intelligence", "abbr" : "wisc-iv", "name" : "wechsler intelligence scale children-fourth edition", "publisher" : "the psychological corporation" }, { "_id" : "osaualrx97merzuda", "category_id" : "7", "active" : "true", "category" : "speech , language", "abbr" : "wojo", "name" : "wechsler intelligence", "publisher" : "the psychological corporation" }, { "_id" : "57c62a784b94c533b656dba8", "category_id" : "5", "active" : "true", "category" : "behavioral", "abbr" : "cars", "name" : "cars", "publisher" : "the psychological corporation" } ],
); },
dynamically loading entries "testlist" collection "tests" array.
testlist = new mongo.collection('testlist'); studentschema = new simpleschema({ tests: { type: [object], blackbox: true, optional: true, autovalue: function () { return testlist.find().fetch(); },
Comments
Post a Comment