tanstack-solid-live-query
БесплатноБез исполняемых скриптовНе проверенApply TanStack Solid DB useLiveQuery patterns. Use when building or debugging reactive queries with @tanstack/solid-db.
от KyleAMathews★ 16 звёзд на GitHubОб этом скилле
TanStack Solid DB - useLiveQuery Skill
Guide for using useLiveQuery from @tanstack/solid-db to create reactive queries over TanStack DB collections.
Import
import { useLiveQuery } from '@tanstack/solid-db';
Core Patterns
Pattern 1: Direct Collection Access (Simplest)
Use when you want all items from a collection with no server-side filtering:
import { useLiveQuery } from '@tanstack/solid-db';
function MyComponent() {
const db = useMyDB(); // Your DB context
const query = useLiveQuery(() => db.collections.events);
// Access data as a reactive array (it's a Solid store, not an accessor!)
const events = query.data; // NO () - it's already reactive
// Or use in JSX directly
return (
<For each={query.data}>
{(event) => <EventCard event={event} />}
</For>
);
}
IMPORTANT: When using direct collection access, query.data is a Solid store array (reactive), not an accessor function. Do NOT call it with query.data().
Pattern 2: Query Builder with Filtering
Use TanStack DB's query builder to push filtering/sorting into the database:
const query = useLiveQuery((q) =>
q.from({ events: db.collections.events })
.where(({ events }) => eq(events.language, 'en'))
.select(({ events }) => ({ id: events.id, title: events.title }))
);
// Access data directly - it's a reactive store array
const filteredData = query.data;
Pattern 3: Reactive Query with Signals
Query functions automatically track signal dependencies:
const [minPriority, setMinPriority] = createSignal(5);
const query = useLiveQuery((q) =>
q.from({ todos: db.collections.todos })
.where(({ todos }) => gte(todos.priority, minPriority())) // Signal tracked!
);
// When minPriority() changes, query automatically re-runs
Pattern 4: Joins Across Collections
const query = useLiveQuery((q) =>
q.from({ issues: db.collections.issues })
.join({ users: db.collections.users }, ({ issues, users }) =>
eq(issues.userId, users.id)
)
.select(({ issues, users }) => ({
issueId: issues.id,
issueTitle: issues.title,
userName: users.name
}))
);
Pattern 5: Includes (Hierarchical/Nested Results)
Use includes to nest related data instead of flattening with joins. Each child result is a live Collection by default:
import { eq, toArray } from '@tanstack/db';
// Each project gets a nested child Collection of its issues
const query = useLiveQuery((q) =>
q.from({ p: db.collections.projects }).select(({ p }) => ({
id: p.id,
name: p.name,
issues: q
.from({ i: db.collections.issues })
.where(({ i }) => eq(i.projectId, p.id)) // correlation condition (required)
.select(({ i }) => ({ id: i.id, title: i.title })),
}))
);
Child Collections must be subscribed to in subcomponents to get reactive updates:
// Parent component
<For each={query()}>
{(project) => (
<div>
{project.name}
<IssueList issuesCollection={project.issues} />
</div>
)}
</For>
// Child component — subscribes to the child Collection
function IssueList(props: { issuesCollection: Collection }) {
const issues = useLiveQuery(() => props.issuesCollection);
return (
<For each={issues()}>
{(issue) => <div>{issue.title}</div>}
</For>
);
}
toArray() alternative — wraps the child query to return a plain array instead of a Collection. The parent row re-emits when children change:
const query = useLiveQuery((q) =>
q.from({ p: db.collections.projects }).select(({ p }) => ({
id: p.id,
name: p.name,
issues: toArray(
q.from({ i: db.collections.issues })
.where(({ i }) => eq(i.projectId, p.id))
.select(({ i }) => ({ id: i.id, title: i.title }))
),
}))
);
// project.issues is now a plain array — no subcomponent subscription needed
Key rules:
- The child
.where()must contain aneq()linking a child field to a parent field (correlation condition) - Correlation can be standalone or inside
and() - Child queries support
.orderBy()and.limit()(applied per parent) - Includes nest arbitrarily (projects → issues → comments)
- Aggregates like
count()work in child queries, computed per parent
Return Value Structure
useLiveQuery returns an object with:
{
data: TResult[], // Reactive array (Solid store) - NO () needed
state: ReactiveMap<TKey, TResult>, // Granular reactive map
collection: Accessor<Collection>, // Underlying collection (call with ())
status: Accessor<CollectionStatus>, // 'loading' | 'ready' | 'error' | etc (call with ())
isLoading: Accessor<boolean>, // Call with ()
isReady: Accessor<boolean>, // Call with ()
isIdle: Accessor<boolean>, // Call with ()
isError: Accessor<boolean>, // Call with ()
isCleanedUp: Ac
Установить tanstack-solid-live-query в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл tanstack-solid-live-query?
Apply TanStack Solid DB useLiveQuery patterns. Use when building or debugging reactive queries with @tanstack/solid-db.
Как установить скилл tanstack-solid-live-query?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tanstack-solid-live-query запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic