store.delete delete by ID
shiroze opened this issue · comments
Juniardy commented
if I have key array structure like this
'Bookmark' = {[ ID : 1, isBooked: true ],[ ID : 3, isBooked: true ]}
I want delete / remove ID : 1, how to do it ?
Jason Merino commented
Assuming you had a structure like this:
const Bookmark = [{
ID: 1,
isBooked: true
}, {
ID: 3,
isBooked: true
}];
And that was stored in simple store you would do something like this to delete it and save it back to simple store.
async function deleteBookmarkById(id) {
const bookmark = await store.get('bookmark');
const newBookmarks = bookmark.filter((b) => b.ID !== id);
await store.save('bookmark', newBookmarks);
return newBookmarks;
}