Collection selector: select everything but variable

In my collection named usernames, to find all documents with a specific property like “Bob” as the name I would do:

usernames.find({name: “Bob”})

Which would only show me documents that have the name Bob. But let’s say there are other people in my collection like Alice and Kat and I want to find and return everyone in the collection whose name is not Bob.

How would I specify a selector to find everything in the usernames collection whose name is not Bob?

I’ve tried:

usernames.find({name: !“Bob”})

Which does not work.
I’m stuck on the syntax. Thank you!

name: { $ne: ‘Bob’ }

2 Likes

because Meteor Collections are Mongo Collections, you can just look up the correct query syntax in the Mongo docs