I have a collection Files
which contain items with a userId
. I want a unique array with all userId
s in the collection.
Here my first approach (code from here: LINK)
Server Method
'uniqUser': function(){
const distinct = Meteor.wrapAsync(Files.rawCollection().distinct,Files.rawCollection());
const result = distinct('userId');
console.log(result)
return result
}
Client Call
uniqUser(){
Meteor.call('uniqUser', function(err, data) {
console.log(data);
return data;
});
}
but my view show nothing!? also no errors...
uniqUser:
{{#each uniqUser}}
<p>{{this}}</p>
{{/each}}
I have to use meteor-reactive-method
LINK:
uniqUser() {
return ReactiveMethod.call("uniqUser");
}
and eveything is fine!