(
table: table,
options: FindOneOptions<table, relations>,
)
| 534 | } |
| 535 | |
| 536 | async findOne< |
| 537 | table extends AnyTable, |
| 538 | relations extends RelationMapForSourceName<TableName<table>> = {}, |
| 539 | >( |
| 540 | table: table, |
| 541 | options: FindOneOptions<table, relations>, |
| 542 | ): Promise<TableRowWith<table, LoadedRelationMap<relations>> | null> { |
| 543 | let query: QueryForTable<table> = this.query(asQueryTableInput(table)).where(options.where) |
| 544 | let orderBy = normalizeOrderByInput(options.orderBy) |
| 545 | |
| 546 | for (let [column, direction] of orderBy) { |
| 547 | query = query.orderBy(column, direction) |
| 548 | } |
| 549 | |
| 550 | if (options.with) { |
| 551 | return query.with(options.with).first() as Promise<TableRowWith< |
| 552 | table, |
| 553 | LoadedRelationMap<relations> |
| 554 | > | null> |
| 555 | } |
| 556 | |
| 557 | return query.first() as Promise<TableRowWith<table, LoadedRelationMap<relations>> | null> |
| 558 | } |
| 559 | |
| 560 | async findMany< |
| 561 | table extends AnyTable, |
no test coverage detected