Home > other >  how to increase value in Realtime Database
how to increase value in Realtime Database

Time:05-24

 const dataFromDbUser = admin.database().ref('Base/'   'users/'  userId);

 dataFromDbUser.on('value',(item)=>{
 item.val().money //10
 })

how can i increase the value of money? Thank you

using node.js

this is what the base looks like

Base:{
   users:{
      22333443:{
         money:10
      }
   }
}

CodePudding user response:

That sounds like a task for ServerValue.increment, so I recommend reading the documentation on atomically incrementing a value?

This also works from the Admin SDKs. So if you're having a problem making it work, please edit your question to show a minimal repro.

  • Related