This commit is contained in:
Peter Maquiran
2024-09-02 15:27:07 +01:00
parent 1b9b4600ab
commit 167df65628
12 changed files with 91 additions and 36 deletions
@@ -15,7 +15,8 @@ export const RoomTableSchema = z.object({
createdAt: z.any(),
expirationDate: z.any().nullable(),
roomType: z.nativeEnum(RoomType),
messages: MessageEntitySchema.array().optional()
messages: MessageEntitySchema.array().optional(),
bold: z.number().optional()
})
export type RoomTable = z.infer<typeof RoomTableSchema>
@@ -85,7 +85,9 @@ export class DexieRepository<T, R> implements IDexieRepository<T, R> {
const ids = await this.table.bulkAdd(documents as any);
return ok(ids);
} catch (error) {
Logger.error(`dexie.js failed to insert many into ${this.table.name}`, {
data: document
});
return err(new Error('Failed to insert multiple documents: ' + error.message));
}
}
@@ -155,6 +157,9 @@ export class DexieRepository<T, R> implements IDexieRepository<T, R> {
const documents: any = await this.table.where(filter).toArray();
return ok(documents);
} catch (error) {
Logger.error(`dexie.js failed to find into ${this.table.name}`, {
data: filter,
});
return err(new Error('Failed to find documents: ' + error.message));
}
}
@@ -164,7 +169,10 @@ export class DexieRepository<T, R> implements IDexieRepository<T, R> {
const document = await this.table.where(filter).first();
return ok(document);
} catch (error) {
console.log(filter)
Logger.error(`dexie.js failed to findOne into ${this.table.name}`, {
data: filter,
error
});
return err(new Error('Failed to find document: ' + error.message));
}
}