In SQL I could do something like
SELECT myNum, (myNum+1) as `increment` FROM myTable
effectively doing arbitrary math and other functions and returning those as a field in the result. Can the same be done with MongoDB?
db.test.find({}, {_id:1, myNum:1, increment:function() { return this.myNum + 1;}});
That does not return an "increment" field like I'd expect.
All other related questions I could find on this topic deal with GROUPed queries, which this one is not; I'm just adding a "virtual" field to the document when it's fetched (client-side computed?).
Alternately, this problem seems to be a "map" without a "reduce"; each row has its own calculated field. Is there any way to return the result of a map function as a result/cursor?