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

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -