|
1 | 1 | import { Knex } from 'knex'
|
2 | 2 | import ResultTypes = require('./result')
|
3 | 3 |
|
| 4 | +type AnyOrUnknownToOther<T1, T2> = unknown extends T1 ? T2 : T1; |
| 5 | +type SafePartial<T> = Partial<AnyOrUnknownToOther<T, {}>>; |
| 6 | + |
4 | 7 | type PaginationOptions = {
|
5 | 8 | page?: number;
|
6 | 9 | pageSize?: number;
|
@@ -397,6 +400,73 @@ export default class Repository<TRecord extends {} = any, TResult = any> {
|
397 | 400 | : Knex.DbRecordArr<TRecord> | ReadonlyArray<Knex.DbRecordArr<TRecord>>
|
398 | 401 | ): T;
|
399 | 402 |
|
| 403 | + static del( |
| 404 | + returning?: '*', |
| 405 | + options?: DMLOptions |
| 406 | + ): Knex.QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>; |
| 407 | + del< |
| 408 | + TKey extends StrKey<TRecord>, |
| 409 | + TResult2 = DeferredKeySelection.Augment< |
| 410 | + UnwrapArrayMember<TResult>, |
| 411 | + TRecord, |
| 412 | + TKey |
| 413 | + >[] |
| 414 | + >( |
| 415 | + returning?: TKey, |
| 416 | + options?: DMLOptions |
| 417 | + ): Knex.QueryBuilder<TRecord, TResult2>; |
| 418 | + |
| 419 | + del< |
| 420 | + TKey extends StrKey<TRecord>, |
| 421 | + TResult2 = DeferredKeySelection.Augment< |
| 422 | + UnwrapArrayMember<TResult>, |
| 423 | + TRecord, |
| 424 | + TKey |
| 425 | + >[] |
| 426 | + >( |
| 427 | + returning?: readonly TKey[], |
| 428 | + options?: DMLOptions |
| 429 | + ): Knex.QueryBuilder<TRecord, TResult2[]>; |
| 430 | + del<TResult2 = SafePartial<TRecord>[]>( |
| 431 | + returning?: string | readonly string[], |
| 432 | + options?: DMLOptions |
| 433 | + ): Knex.QueryBuilder<TRecord, TResult2>; |
| 434 | + del<TResult2 = number>(): Knex.QueryBuilder<TRecord, TResult2>; |
| 435 | + |
| 436 | + static delete( |
| 437 | + returning?: '*', |
| 438 | + options?: DMLOptions |
| 439 | + ): Knex.QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>; |
| 440 | + delete< |
| 441 | + TKey extends StrKey<Knex.ResolveTableType<TRecord>>, |
| 442 | + TResult2 = DeferredKeySelection.Augment< |
| 443 | + UnwrapArrayMember<TResult>, |
| 444 | + Knex.ResolveTableType<TRecord>, |
| 445 | + TKey |
| 446 | + >[] |
| 447 | + >( |
| 448 | + returning?: TKey, |
| 449 | + options?: DMLOptions |
| 450 | + ): Knex.QueryBuilder<TRecord, TResult2>; |
| 451 | + delete< |
| 452 | + TKey extends StrKey<TRecord>, |
| 453 | + TResult2 = DeferredKeySelection.Augment< |
| 454 | + UnwrapArrayMember<TResult>, |
| 455 | + TRecord, |
| 456 | + TKey |
| 457 | + >[] |
| 458 | + >( |
| 459 | + returning?: readonly TKey[], |
| 460 | + options?: DMLOptions |
| 461 | + ): Knex.QueryBuilder<TRecord, TResult2>; |
| 462 | + |
| 463 | + static delete<TResult2 = any>( |
| 464 | + returning?: string | readonly (string | Knex.Raw)[] | Knex.Raw, |
| 465 | + options?: DMLOptions |
| 466 | + ): QueryBuilder<TRecord, TResult2>; |
| 467 | + |
| 468 | + static delete<TResult2 = number>(): Knex.QueryBuilder<TRecord, TResult2>; |
| 469 | + static truncate(): Knex.QueryBuilder<TRecord, void>; |
400 | 470 | static join: Knex.Join<TRecord, TResult>;
|
401 | 471 | static joinRaw: Knex.JoinRaw<TRecord, TResult>;
|
402 | 472 | static innerJoin: Knex.Join<TRecord, TResult>;
|
|
0 commit comments