[SERVER-4079] Computed Fields Created: 16/Oct/11  Updated: 06/Dec/22  Resolved: 15/Aug/17

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

Type: New Feature Priority: Major - P3
Reporter: John Crenshaw Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Issue Links:
Related
is related to SERVER-2549 expression native support , find({ a... Closed
Assigned Teams:
Query
Participants:

 Description   

I keep wishing I could have a computed field:

Basic idea:

db.people.find( { firstname : "John" }, { _id: 1, name : function() {return this.firstname + ' ' + this.lastname;} } )

Where it gets interesting:

db.people.find( { score: {'$gt': 10} }, { _id: 1, score: function() {return this.foo + this.bar + this.baz;} } ).sort(score: 5)

Obviously if you know in advance that you're going to need to run a query like this frequently it makes sense to try to precompute the value, but sometimes a query is so rare that precomputing is a waste, and in some cases you don't know enough information in advance.



 Comments   
Comment by Ramon Fernandez Marina [ 15/Aug/17 ]

bugslayer, we're going to close this ticket since the operations you describe are achievable using aggregation. If you find yourself needing an operation that the aggregation framework does not yet support please open a new ticket requesting such functionality.

Thanks,
Ramón.

Comment by Ramon Fernandez Marina [ 06/Jul/16 ]

bugslayer, have you tried using the aggregation framework? It contains a lot of new functionality since this ticket was created, and I believe it will address your needs.

Thanks,
Ramón.

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