basic user-tailored UI
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ export interface Entity<T> {
|
||||
construct: (data: T) => T;
|
||||
create: (data: Omit<T, "id">) => Promise<T>;
|
||||
createMany: (data: Omit<T, "id">[]) => Promise<T[]>;
|
||||
findAll: () => Promise<T[]>;
|
||||
findAll: (user?: { userId: string }) => Promise<T[]>;
|
||||
findById: (id: string) => Promise<T | undefined>;
|
||||
update: (id: string, data: Partial<T>) => Promise<void>;
|
||||
delete: (id: string) => Promise<void>;
|
||||
|
||||
@@ -58,11 +58,13 @@ export function getDb(POSTGRES_CONNECTION_STRING: string) {
|
||||
.execute();
|
||||
return insertedRows;
|
||||
},
|
||||
findAll: async () => {
|
||||
const rows = await dbClient
|
||||
.selectFrom("conversations")
|
||||
.selectAll()
|
||||
.execute();
|
||||
findAll: async (user) => {
|
||||
const userId = user?.userId;
|
||||
let query = await dbClient.selectFrom("conversations");
|
||||
if (userId) {
|
||||
query = query.where("userId", "=", userId);
|
||||
}
|
||||
const rows = query.selectAll().execute();
|
||||
return rows;
|
||||
},
|
||||
findById: async (id) => {
|
||||
|
||||
Reference in New Issue
Block a user