Reputation: 3696
I have this function in Meteor:
Posts.find({_id: {$ne: ls._id}}, function(err, item) {
if (err) {return console.error(err)};
console.log("item: " + String(item));
});
But I am getting this error:
Exception while invoking method 'updateSuggestions' Error: Match error: Failed Match.OneOf or Match.Optional validation
This does work though:
Posts({_id: {$ne: ls._id}});
So I think its something with the callback function but I'm really not sure what.
Upvotes: 1
Views: 2535
Reputation: 64332
find doesn't take a callback as a parameter.
On the client, find
is synchronous so the callback is unnecessary. On the server, find
appears synchronous due to meteor's use of fibers.
Either way, you want something like this:
let posts = Posts.find({_id: {$ne: ls._id}}).fetch();
console.log(posts);
See common mistakes for more details on find
and fetch
.
Upvotes: 4