mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-06 21:03:20 +08:00
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.
This commit is contained in:
17
backend/src/utils/database.js
Normal file
17
backend/src/utils/database.js
Normal file
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user