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 patternconstrow=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.
Describe the bug
When using
useLiveQueryfrom@tanstack/solid-dbwith.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 forfindOne().To Reproduce
(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 (orundefinedif no match), notT[].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.