mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
improve chat
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Result, ok, err } from 'neverthrow';
|
||||
import { EntityTable } from 'Dexie';
|
||||
import { ZodError, ZodObject, ZodSchema } from 'zod';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
|
||||
// Define a type for the Result of repository operations
|
||||
type RepositoryResult<T, E> = Result<T, Error | ZodError<E>>;
|
||||
@@ -28,6 +29,9 @@ export class DexieRepository<T> {
|
||||
return err(new Error('Failed to insert document: ' + error.message));
|
||||
}
|
||||
} else {
|
||||
Logger.error(`dexie.js failed to insert into ${this.table.name}, invalid data`, {
|
||||
data: document
|
||||
});
|
||||
return err((dataValidation as unknown as ZodError<T>))
|
||||
}
|
||||
}
|
||||
@@ -45,6 +49,9 @@ export class DexieRepository<T> {
|
||||
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}, invalid data`, {
|
||||
data: document
|
||||
});
|
||||
return err(new Error('Failed to insert multiple documents: ' + error.message));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user