MCPcopy
hub / github.com/drizzle-team/drizzle-orm / get

Method get

drizzle-orm/src/d1/session.ts:238–259  ·  view source on GitHub ↗
(placeholderValues?: Record<string, unknown>)

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 6

valuesMethod · 0.95
fillPlaceholdersFunction · 0.90
mapResultRowFunction · 0.90
logQueryMethod · 0.65
thenMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected