refactor(database): ♻️ Simplify User and Note logic further

This commit is contained in:
Jesse Wierzbinski 2024-12-09 13:50:46 +01:00
parent a8541bdc44
commit 83399ba5f1
No known key found for this signature in database
6 changed files with 67 additions and 107 deletions

11
utils/lib.ts Normal file
View file

@ -0,0 +1,11 @@
type ElementWithId = { id: string };
export const mergeAndDeduplicate = <T extends ElementWithId>(
...elements: T[][]
): T[] =>
elements
.reduce((acc, val) => acc.concat(val), [])
.filter(
(element, index, self) =>
index === self.findIndex((t) => t.id === element.id),
);