0
 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
      }
   }
}
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Eduard
  • 27
  • 5

1 Answers1

0

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    admin.database().ref('Base/' + 'users/'+ userId).update({ money: admin.database.ServerValue.increment(10) }); works, thanks a lot))) – Eduard May 24 '22 at 07:42