-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.0.0
-
Component/s: JavaScript, Querying
-
None
-
Environment:All
-
Query
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.
- is related to
-
SERVER-2549 expression native support , find({ a: { $lt : b*2 } })
- Closed