.pull()

Removes all elements with the same value as the provided value from an array based on the provided key.

pull(key, value)

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'] }

Last updated