Skip to content
Source
Sign inSign up
TanStack/db

[solid-db] useLiveQuery with .findOne() returns an array instead of a single object #1399

Send to my agent
Closedersbeth(GitHub profile, opens in a new tab) opened this issue 0 comments
  • I've validated the bug against the latest version of DB packages

Describe the bug When using useLiveQuery from @tanstack/solid-db with .findOne() on the query builder, the returned data behaves like a list query (array with one element) instead of a single result (T | undefined), which contradicts the live queries documentation for findOne().

To Reproduce

import { eq, useLiveQuery } from "@tanstack/solid-db";
// Example pattern
const row = useLiveQuery((q) =>
  q
    .from({ item: myCollection })
    .where(({ item }) => eq(item.id, someId))
    .findOne(),
);
// Observed: row() is an array
// Expected: row() is the object or undefined

(Adjust myCollection / schema to any local collection; the issue is about the shape returned by the Solid adapter, not domain data.)

Expected behavior After .findOne(), the live query result should expose a single row (or undefined if no match), not T[].

Actual behavior The result is still an array (e.g. [{ ... }] with length 1), so consumers must use [0] as a workaround.

Additional context Similar problems were fixed in other framework packages by honoring singleResult when exposing data from live queries:

Angular: issue #1261, fix #1273 Vue: issue #1095, fix #1134 @tanstack/solid-db may be missing the same singleResult handling that was added for those adapters. Workaround Omit .findOne() and take the first element from the array (e.g. rows()[0]), or unwrap manually if types suggest a single object but runtime is still an array.

Sign in to join this conversation.