Display all objects in the collection, EXCEPT


#1

How do I display all elements in a collection except the ones that belong to a certain parameter.

To display all the elements, I do;

     return Posts.find({});

I want to prevent mongo from displaying objects with a certain username, say “food”. I tried the code below but it failed

     return Posts.find({username: ! "food"});

I need some help.


#2

You need to use mongo’s operator Posts.find({username: { $not: "food"}});

MongoDB has a nice documentation where you can read more about all the other operators: https://docs.mongodb.com/manual/reference/operator/query/