.push()
Pushes an element into an array based on the provided key.
push(key, value)
Returns
Description
The updated data from the provided key's root
db.get('people'); // ['Peter', 'Henry']
db.push('people', 'Catherine'); // ['Peter', 'Henry', 'Catherine']
Also allows the use of dot notation:
db.get('user'); // { id: 32171, items: ['sword'] }
db.push('user.items', 'axe'); // { id: 32171, items: ['sword', 'axe'] }
Last updated
Was this helpful?