鑑於我有3種類型的集合和一個動態值,我將如何根據該動態值指定要搜索的集合?你會如何在Meteor中找到一個具有價值的動態集合?
E.g,
array = [
{id: 'one', type: 'profile'},
{id: 'something', type: 'post'},
{id: 'askjdaksj', type: 'comment']
]
我怎麼會孤立型,使之成爲一個集?基本上將車型變爲Collection.find
array[0].type.find({_id: id});
=> Profiles.find({_id: id});
這可能嗎?
這可能有幫助:http://stackoverflow.com/questions/6084858/javascript-use-variable-as-object-name –