.push()

Pushes an element into an array based on the provided key.

push(key, value)

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