The key of the array to search
The callback function to find the elements
The callback function to update the found elements
Optionaloptions: methodOptionsThe options to use
A promise if the driver is async, otherwise an array of updated elements
const db = new GoodDB(new JSONDriver({
path: './database.json'
}));
db.findAndUpdateMany('users',
(user) => user.active === true,
(user) => { user.status = 'verified'; return user; }
);
const db = new GoodDB(new MongoDBDriver({
uri: "..."
}));
await db.connect();
await db.findAndUpdateMany('users',
(user) => user.active === true,
(user) => { user.status = 'verified'; return user; }
);
Find multiple values in an array and update them