You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need help it's very urgent actually I am using MongoDB as a DB and there is a query required where I need to put condition $ne, but it is showing the error consistently (Message: bad query: BadValue: unknown top-level operator: $ne
)
My sample code for idea:
$whereCondition = array(array('status'=>'A'));
$whereCondition2 = array(array('property_verified','P'));
Is this php code? I'm not sure what this has to do with monger, the community clojure driver. In the future please consult the mongodb manual for questions not specific to monger. Here is the manual page for $ne https://docs.mongodb.com/manual/reference/operator/query/ne/
Sorry I might be a little confused by the question but I will try to help.
A more standard way of writing what I think your query is in the mongodb shell (js) would be db.yourCollection.aggregate({$match: {$and: [{status: "A"}, {$ne: {propertyVerified: "P"}}]}}) this query is very confusing in a mongodb context but seems to be a loose translation of the sql expression where status='A' and propertyVerified!='P'. MQL isn't 1:1 translatable to sql this way. The query you may be looking for is {$match: {status: "A", propertyVerified: {$ne: "P}} in MQL the ands are implied and the values of the map/dict/hashMap are the values the field are the expression that field should match.
Because you have something like {$ne: {propertyVerified: "P"}} and mongo is trying to tell you you shouldn't put $ne there and should probably have something like {propertyVerified: {$ne: "P"}}
I need help it's very urgent actually I am using MongoDB as a DB and there is a query required where I need to put condition $ne, but it is showing the error consistently (Message: bad query: BadValue: unknown top-level operator: $ne
)
My sample code for idea:
$whereCondition = array(array('status'=>'A'));
$whereCondition2 = array(array('property_verified','P'));
array('$match'=>array('$and'=>$whereCondition,'$ne'=>$whereCondition2)),
till $and condition its working properly but when adding $ne condition its is throwing same above mentioned error.
My mongo shell version is: 3.2.22
Thanks in advance
Please help
The text was updated successfully, but these errors were encountered: