I have successfully got the one of the users with the lowest referrals using the node native driver
users.find().sort({referrals:1}).limit(1).toArray(function(error,result){
console.log(error||result);
});
^ this works fine
v this and other variations I have tried don't
When I want to make the function better by findAndModify I fail over and over (this is the closest I Think I have got from the docs)
users.findAndModify({},{referrals:1},{$inc:{referrals:1}},{}).toArray(function(error,result){
console.log(error||result);
});
I want to get one of the users with the lowest referrals and ++1 his referrals when I find him