MCPcopy Create free account
hub / github.com/TanStack/db / findOne

Method findOne

packages/db/src/query/builder/index.ts:803–810  ·  view source on GitHub ↗

* Specify that the query should return a single result * @returns A QueryBuilder that returns the first result * * @example * ```ts * // Get the user matching the query * query * .from({ users: usersCollection }) * .where(({users}) => eq(users.id, 1)) * .findOne()

()

Source from the content-addressed store, hash-verified

801 *```
802 */
803 findOne(): QueryBuilder<TContext & SingleResult> {
804 return new BaseQueryBuilder({
805 ...this.query,
806 // TODO: enforcing return only one result with also a default orderBy if none is specified
807 // limit: 1,
808 singleResult: true,
809 }) as any
810 }
811
812 // Helper methods
813 private _getCurrentAliases(): Array<string> {

Calls

no outgoing calls

Tested by 1

buildSingletonQueryFunction · 0.64