(placeholderValues?: Record<string, unknown>)
| 236 | } |
| 237 | |
| 238 | async get(placeholderValues?: Record<string, unknown>): Promise<T['get']> { |
| 239 | const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this; |
| 240 | if (!fields && !customResultMapper) { |
| 241 | const params = fillPlaceholders(query.params, placeholderValues ?? {}); |
| 242 | logger.logQuery(query.sql, params); |
| 243 | return await this.queryWithCache(query.sql, params, async () => { |
| 244 | return stmt.bind(...params).all().then(({ results }) => results![0]); |
| 245 | }); |
| 246 | } |
| 247 | |
| 248 | const rows = await this.values(placeholderValues); |
| 249 | |
| 250 | if (!rows[0]) { |
| 251 | return undefined; |
| 252 | } |
| 253 | |
| 254 | if (customResultMapper) { |
| 255 | return customResultMapper(rows) as T['all']; |
| 256 | } |
| 257 | |
| 258 | return mapResultRow(fields!, rows[0], joinsNotNullableMap); |
| 259 | } |
| 260 | |
| 261 | override mapGetResult(result: unknown, isFromBatch?: boolean): unknown { |
| 262 | if (isFromBatch) { |
nothing calls this directly
no test coverage detected