2017-07-27 5 views
0

defaultValue内の "テスト"を以下のように定義するのではなく、単純なスキーマのデフォルト値をMeteor jsのコレクションに呼び出す方法を教えてください。可能であれば、defaultValueを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 for Children-Fourth Edition", 
     "publisher" : "The Psychological Corporation" 
    }, 

    { 
     "_id" : "osAuaLrX97meRZuda", 
     "category_id" : "7", 
     "active" : "true", 
     "category" : "Speech and 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" 
    } 
], 

); }、

答えて

0

"TestList"コレクションのすべてのエントリを動的に "tests"配列にロードします。

TestList = new Mongo.Collection('testList'); 
StudentSchema = new SimpleSchema({ 

tests: { 
type: [Object], 
blackbox: true, 
optional: true, 
autoValue: function() { 
return TestList.find().fetch(); 
}, 
関連する問題