• Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.0
    • Component/s: JavaScript, Querying
    • Labels:
      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.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            bugslayer John Crenshaw
            Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: