.add()

Adds the provided value to the value of the provided key. If no existing number, the provided value will be added to 0 (zero).

add(key, value)

Parameter

Description

key

String

The key that will have its value incremented

value

Number

The value to increment

Returns

Description

The updated data from the provided key's root

db.get('balance'); // 350

db.add('balance', 500); // 850

Also allows the use of dot notation:

db.get('account'); // { owner: '5antos', balance: 800 }

db.add('account.balance', 200); // { owner: '5antos', balance: 1000 }

Last updated