I would like to update the first field returned by a query using a sort condition. Is this possible? At the moment I need to use findAndModify to do this, as it provides a `sort` option, like so:
videos.findAndModify({pos: 0, [['index', 1]], {$set: {pos: 1}}, function(err, doc) {});
The above updates the first video with a `pos` of 0 to a `pos` of 1. However, this returns the old document whereas I do need it.
Therefore it would be more appropriate and less resource consuming for me to use the update command. However, it does not seem to have a sort parameter. I would like to use it like so:
videos.update({pos: 0, [['index', 1]], {$set: {pos: 1}}, {safe: false});
Achieving the same objective while not returning the original object.
Is this possible?
(Note that my examples use the Node.js driver, which uses Javascript and should therefore be almost identical to Mongo's console Javascript syntax).
Tom