App: Add TS type information
This commit is contained in:
7
src/lib/database.ts
Normal file
7
src/lib/database.ts
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Retrieve an arbitrary object with a matching ID from an Array.
|
||||
* Supposed to use on collections returned by the PocketBase API.
|
||||
*/
|
||||
export const get_by_id = <T extends object>(objects: Array<T>, id: string): T | undefined => {
|
||||
return objects.find((o: T) => ("id" in o ? o.id === id : false));
|
||||
};
|
||||
Reference in New Issue
Block a user