MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / getSingleResult

Method getSingleResult

packages/sql/src/query/QueryBuilder.ts:2651–2658  ·  view source on GitHub ↗

* Executes the query, returning the first result or null

()

Source from the content-addressed store, hash-verified

2649 * Executes the query, returning the first result or null
2650 */
2651 async getSingleResult(): Promise<Loaded<Entity, Hint, Fields> | null> {
2652 if (!this.#state.finalized) {
2653 this.limit(1);
2654 }
2655
2656 const [res] = await this.getResultList(1);
2657 return res || null;
2658 }
2659
2660 /**
2661 * Executes count query (without offset and limit), returning total count of results

Calls 2

limitMethod · 0.95
getResultListMethod · 0.95

Tested by 1

getOneWithStudentsMethod · 0.64