| 558 | } |
| 559 | |
| 560 | async findMany< |
| 561 | table extends AnyTable, |
| 562 | relations extends RelationMapForSourceName<TableName<table>> = {}, |
| 563 | >( |
| 564 | table: table, |
| 565 | options?: FindManyOptions<table, relations>, |
| 566 | ): Promise<Array<TableRowWith<table, LoadedRelationMap<relations>>>> { |
| 567 | let query: QueryForTable<table> = this.query(asQueryTableInput(table)) |
| 568 | |
| 569 | if (options?.where) { |
| 570 | query = query.where(options.where) |
| 571 | } |
| 572 | |
| 573 | let orderBy = normalizeOrderByInput(options?.orderBy) |
| 574 | for (let [column, direction] of orderBy) { |
| 575 | query = query.orderBy(column, direction) |
| 576 | } |
| 577 | |
| 578 | if (options?.limit !== undefined) { |
| 579 | query = query.limit(options.limit) |
| 580 | } |
| 581 | |
| 582 | if (options?.offset !== undefined) { |
| 583 | query = query.offset(options.offset) |
| 584 | } |
| 585 | |
| 586 | if (options?.with) { |
| 587 | return query.with(options.with).all() as Promise< |
| 588 | Array<TableRowWith<table, LoadedRelationMap<relations>>> |
| 589 | > |
| 590 | } |
| 591 | |
| 592 | return query.all() as Promise<Array<TableRowWith<table, LoadedRelationMap<relations>>>> |
| 593 | } |
| 594 | |
| 595 | async count<table extends AnyTable>( |
| 596 | table: table, |