Favorieten toegevoegd aan de navigatiebalk en sidebar.
This commit is contained in:
@@ -72,6 +72,37 @@ class ShoppingListRepository {
|
||||
`).run(listId);
|
||||
}
|
||||
|
||||
clearItems(listId) {
|
||||
return db.prepare(`
|
||||
DELETE FROM shopping_list_items
|
||||
WHERE list_id = ?
|
||||
`).run(listId);
|
||||
}
|
||||
|
||||
addItems(listId, items) {
|
||||
if (!items.length) return 0;
|
||||
|
||||
const insert = db.prepare(`
|
||||
INSERT INTO shopping_list_items (list_id, product_id, amount, checked, sort_order)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`);
|
||||
|
||||
const transaction = db.transaction(() => {
|
||||
for (const item of items) {
|
||||
insert.run(
|
||||
listId,
|
||||
item.product_id,
|
||||
item.amount ?? 1,
|
||||
item.checked ?? 0,
|
||||
item.sort_order ?? 0
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
transaction();
|
||||
return items.length;
|
||||
}
|
||||
|
||||
deleteItem(listId, itemId) {
|
||||
return db.prepare(`
|
||||
DELETE FROM shopping_list_items WHERE id = ? AND list_id = ?
|
||||
|
||||
Reference in New Issue
Block a user