-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.d.ts
35 lines (29 loc) · 1.21 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
declare module 'objection-js-soft-delete' {
import { Model, QueryBuilder } from 'objection';
class SoftDeleteQueryBuilder<M extends Model, R = M[]> extends QueryBuilder<M, R> {
ArrayQueryBuilderType: SoftDeleteQueryBuilder<M>;
NumberQueryBuilderType: SoftDeleteQueryBuilder<M, number>;
delete(): this['NumberQueryBuilderType'];
hardDelete(): this['NumberQueryBuilderType'];
undelete(): this['NumberQueryBuilderType'];
whereDeleted(): this['ArrayQueryBuilderType'];
whereNotDeleted(): this['ArrayQueryBuilderType'];
}
interface SoftDeleteInstance<T extends typeof Model> {
//@ts-ignore
QueryBuilderType: SoftDeleteQueryBuilder<this, this[]>;
}
interface SoftDeleteStatic<T extends typeof Model> {
QueryBuilder: typeof SoftDeleteQueryBuilder;
isSoftDelete: boolean;
namedFilters(): object;
new (): SoftDeleteInstance<T> & T['prototype'];
}
export default function softDelete<T extends typeof Model>(
options?: Partial<{
columnName: string;
deletedValue: Date | boolean | number;
notDeletedValue: boolean | null;
}>,
): (model: T) => Omit<T, 'new'> & SoftDeleteStatic<T>;
}