node.js - Mongoose async queries -


i have site on nodejs-express , when user increment balance:

user.update({steamid: user.steamid}, {$set: {wallet: user.wallet + 1)}}, function(err){   if(err) console.log(err); }); 

but when user increment "wallet" @ least twice in row mongoose add 1 point in "wallet". should do? maybe add queue array , call async?

you should increment instead of set.

user.update({steamid: user.steamid}, {$inc:{wallet:1}}, function(err){     if(err)console.log(err) }); 

i use when don't need information model quantity , need difference value operate on model itself.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -