Reputation: 995
I'm trying to use a Meteor app to get documents from a mongodb database (using Meteor's Collection), but I only want documents that have a certain note field does not exist in it.
I tried to do:
Documents.findOne({id:'abcd',note:{"$exists":'true'}});
where documents is my Collection but it returns the first found result (which doesn't have a note field) rather than the one I need. I also tried using $exists but that doesn't work either.
Can someone please help me out here? I'm guessing I'm making a really silly error somewhere, but I just can't put my finger on it
Thanks in advance :)
Upvotes: 3
Views: 5481
Reputation: 1558
Try taking out the quotes around $exists. Like
Documents.findOne({id: 'abcd', note:{ $exists: true}});
That should work. Also, in case you didn't know, the docs are great for mongodb.
Upvotes: 2
Reputation: 75975
Try
Documents.findOne({id:'abcd',note:{"$exists":true}});
Remember the true
is parsed as a boolean in JSON only if it doesn't have encapsulated quotes
Upvotes: 6