Files
Sub-Store/backend/src/utils/database.js
Peng-YM 84b4dba425 refactor: Migrate to API v2
- Added auto schema migration
- Refactored /api/subs, /api/collections, /api/artifacts. Now these APIs will return array instead of object. This enables sorting items in the future.
2022-07-06 18:12:36 +08:00

18 lines
437 B
JavaScript

export function findByName(list, name) {
return list.find((item) => item.name === name);
}
export function findIndexByName(list, name) {
return list.find((item) => item.name === name);
}
export function deleteByName(list, name) {
const idx = findIndexByName(list, name);
list.splice(idx, 1);
}
export function updateByName(list, name, newItem) {
const idx = findIndexByName(list, name);
list[idx] = newItem;
}