mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
soft delete
This commit is contained in:
@@ -6,7 +6,7 @@ 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>>;
|
||||
|
||||
export class DexieRepository<T> {
|
||||
export class DexieRepository<T, R> {
|
||||
private table: EntityTable<any, any>;
|
||||
private ZodSchema: ZodSchema<T>
|
||||
private ZodPartialSchema: ZodSchema<T>
|
||||
@@ -94,17 +94,16 @@ export class DexieRepository<T> {
|
||||
}
|
||||
}
|
||||
|
||||
async find(filter: Object): Promise<RepositoryResult<T[], T[]>> {
|
||||
async find(filter: Partial<T>): Promise<RepositoryResult<R[], T[]>> {
|
||||
try {
|
||||
const documents: any = await this.table.where(filter).toArray();
|
||||
console.log('documents', {documents})
|
||||
return ok(documents);
|
||||
} catch (error) {
|
||||
return err(new Error('Failed to find documents: ' + error.message));
|
||||
}
|
||||
}
|
||||
|
||||
async findOne(filter: Object): Promise<RepositoryResult<T | undefined, T>> {
|
||||
async findOne(filter: Partial<T>): Promise<RepositoryResult<T | undefined, T>> {
|
||||
try {
|
||||
const document = await this.table.where(filter).first();
|
||||
return ok(document);
|
||||
|
||||
Reference in New Issue
Block a user