[SERVER-9366] Expose projection (aggregation) operators in regular find queries Created: 17/Apr/13  Updated: 06/Dec/22  Resolved: 16/Jan/18

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

Type: Improvement Priority: Major - P3
Reporter: Alon Horev Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-974 $subset query operator Closed
is depended on by SERVER-16896 Provide "is subset" array functionali... Closed
Duplicate
duplicates SERVER-30731 Add $expr support in MatchExpression ... Closed
is duplicated by SERVER-11072 Expose $project in find Closed
is duplicated by SERVER-9272 Querying latest document based on a s... Closed
Related
related to SERVER-11345 Allow update to compute expressions u... Closed
Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Participants:

 Description   

Operators like: ($)add, divide, multiply, hour, etc' can be very useful in regular 'find' queries and not only aggregations.

Is there any special reason for this lack of consistency between regular 'find' queries and the aggregation framework?

This is possibly linked to: allow referencing fields on the right-hand-side of operators: SERVER-7623



 Comments   
Comment by Asya Kamsky [ 16/Jan/18 ]

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.

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