Pushes an element into an array based on the provided key.
Last updated 2 years ago
Parameter
Description
key
The key of the target array
value
The value to push into the array
Returns
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'] }