2017-04-13 9 views
1

私にはuserIdのアイテムを含むコレクションFilesがあります。コレクション内にすべてuserIdのユニークな配列が必要です。メテオコレクションからユニークなアイテムを取得

ここに私の最初のアプローチ(ここからコード:LINK

サーバー方法

'uniqUser': function(){ 
    const distinct = Meteor.wrapAsync(Files.rawCollection().distinct,Files.rawCollection()); 
    const result = distinct('userId'); 
    console.log(result) 
    return result 
} 

クライアント呼び出し

uniqUser(){ 
    Meteor.call('uniqUser', function(err, data) { 
    console.log(data); 
    return data; 
    }); 
} 

console.logはよさそうだ: enter image description here

私の見解は何も表示されません!また、エラー...

uniqUser: 
{{#each uniqUser}} 
    <p>{{this}}</p> 
{{/each}} 
+0

あなたの 'uniqUser'は' {uniqUser:["fsdfd"、 "ooop"]} 'のようなオブジェクトのキーでなければなりません –

答えて

0

は私がmeteor-reactive-methodLINK使用する必要がありません:

uniqUser() { 
    return ReactiveMethod.call("uniqUser"); 
    } 

をしてeveythingは大丈夫です!

関連する問題