How to compare a field with another in Mongodb aggregation? -


I have several levels in the pipeline, now I would like to compare two areas as follows:

  db.collection.aggregate ({...}, {$ match: {firstfield: {$ gte: "$ secondfield"}}})   

How to write this question? Close, but the actual greeting is slightly different:

 {code> db.collection.aggregate ({{" first project ": {" firstfield ": 1," secondfield ": 1," difference ": {" $ gte ": [" $ firstfield " , "$ secondfield"]}}}, {"$ match": {"difference": true}}]   

for a slightly different invitation, (or possibly) On field comparison, a true | False the value can be returned.

This allows you to filter later with the phase Pipeline to present the "Include Include" results depending on the logical state.

Comments

Popular posts from this blog

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

c++ - Redefined variable in the other module -