MongoDB $ ne Explanation

The official MongoDB api wrote very little about $ ne http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24ne

So, when I came across something like

db.papers.update({"authors cited" : {"$ne" : "Richie"}},
... {$push : {"authors cited" : "Richie"}})

I have no choice but to become completely embarrassed. Can someone explain this to me?

+3
source share
1 answer

This will add Richie to the list of authors cited for an article that does not yet have Richie as the author.

An alternative would be to use $addToSet.

, , {{ : { "$ ne": "Richie" }} , " ", , " "?

. ( , , ), . Mongo "multikeys" .

, , , , . , . +1 , .

+2

All Articles