const positions = createCollection(
queryCollectionOptions({
id: 'positions',
syncMode: 'on-demand',
queryClient,
getKey: (p) => p.id,
staleTime: 10_000,
queryKey: (opts) => {
const accountId = extractAccountId(opts)
return ['positions', accountId ?? 'all']
},
queryFn: async (ctx) => {
const accountId = extractAccountId(ctx.meta?.loadSubsetOptions)
return api.getPositions({ accountId })
},
})
)
function PositionList({ accountId }) {
const { data } = useLiveQuery(
(q) => q.from({ pos: positions })
.where(({ pos }) => eq(pos.accountId, accountId))
.select(({ pos }) => pos),
[accountId]
)
return <List data={data} />
}
const positions = createCollection(
queryCollectionOptions({
id: 'positions',
syncMode: 'on-demand',
queryClient,
getKey: (p) => p.id,
staleTime: 10_000,
queryKey: (opts) => {
const accountId = extractAccountId(opts)
return ['positions', accountId ?? 'all']
},
queryFn: async (ctx) => {
const accountId = extractAccountId(ctx.meta?.loadSubsetOptions)
return api.getPositions({ accountId })
},
})
)
function PositionList({ accountId }) {
const { data } = useLiveQuery(
(q) => q.from({ pos: positions })
.where(({ pos }) => eq(pos.accountId, accountId))
.select(({ pos }) => pos),
[accountId]
)
return <List data={data} />
}