Pulls all elements with the same value as the provided value from an array based on the provided key.
Last updated 3 years ago
Parameter
Description
key
The key of the target array
value
Any
The value to pull from the array
Returns
The updated data from the provided key's root
db.get('numbers'); // [1, 2, 3, 2, 4, 3, 1, 1] db.pull('numbers', 1); // [2, 3, 2, 4, 3]
Also allows the use of dot notation:
db.get('user'); // { id: 32171, items: ['sword', 'axe'] } db.pull('user.items', 'bow'); // { id: 32171, items: ['sword', 'axe'] } db.pull('user.items', 'sword'); // { id: 32171, items: ['axe'] }