Increment and update in Firebase

Let's assume that you have the following object:

    'name': 'Erik',
    'age': 30,
    'posts': {
        '-MMFpPpFFi3CjLARb59_': 'Hi'

To increment the value of a property, you can use firebase.database.ServerValue.increment().

For example, if you wanted to increment the value of age and update name at the same time:

let object = {
    name: 'Erik Martín Jordán',
    age: firebase.database.ServerValue.increment(1)

// Calling update method

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.