[SERVER-7623] comparison operation right hand side should be expressions Created: 12/Nov/12  Updated: 06/Dec/22  Resolved: 23/Nov/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Eliot Horowitz (Inactive) Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 18
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CSHARP-847 Linq provider needs to support non-co... Closed
Duplicate
duplicates SERVER-30731 Add $expr support in MatchExpression ... Closed
Related
related to SERVER-2702 Compare document fields in queries Closed
related to SERVER-30731 Add $expr support in MatchExpression ... Closed
Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Participants:

 Description   

{ x :

{ $sum : [ "$y" , 3 ] }

}



 Comments   
Comment by Asya Kamsky [ 23/Nov/17 ]

This can now be done using $expr, which allows you to use aggregation expressions in the match language:

db.coll.find( { $expr : { $eq: [ "$x", {$add: [ "$y" , 3 ] } ] } })

See documentation for the feature here: https://docs.mongodb.com/master/reference/operator/query/expr/

The work was done as SERVER-30731.

Comment by William Cross [ 22/Mar/17 ]

+1. Would love this to be the case.

Comment by Nicholas Johnson [ 15/Jul/15 ]

This would remove an area of inconsistency, and would make find much more useful. It would be possible to do a lot more before dipping into the aggregate pipeline, and would discourage new developers from using $where unnecessarily.

Comment by Patrick Grandjean [ 21/Feb/13 ]

db.col.find({ "a.b":

{ $eq: "$a.c" }

})

That would change my life

Generated at Thu Feb 08 03:15:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.