I'm trying to do something like this:
select * from table where not (a=3 and b=4 and c=3 or x=4)
I would expect this to work:
db.table.find( {
$not : {
$or : [
{ $and : [ { a : 3 },
{ b : 4 },
{ c : 3 }
] } ,
{ x : 4 }
}
} )
But it does not work.
I have read this article
And something like this: {a : { $ne : 3}, b : { $ne : 4} ...}. does
not suit me.
Because: my program takes DIFFERENT queries like this (a=3 and b=4 and c=3 or x=4) from users (queries to multilevel embedded objects and arrays).
And to write procedure, which automatically apply $not to those queries looks
long and thankless task. have you any ideas?
P.S. Why does mongo not have a simple way to do that?
For example, to find all the documents that match the condition, and to take from the collection of the remaining documents?