Details

      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.

        Issue Links

          Activity

          • Comments
          Hide
          ramon.fernandez Ramon Fernandez added a comment -

          John Crenshaw, 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.

          Show
          ramon.fernandez Ramon Fernandez added a comment - John Crenshaw , 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.

            People

            • Votes:
              6 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since reply:
                21 weeks, 6 days ago
                Date of 1st Reply: