@@ -39,7 +39,8 @@ export const getAccountCollection = defineCollection(
3939export const getCatalogGridLiveQuery = defineLiveQuery ((scope ? : DbScope ) =>
4040 liveQueryCollectionOptions ({
4141 id: ` catalog-grid ` ,
42- query : (q ) => q .from ({ c: getCatalogCollection (scope ) }).orderBy (({ c }) => c .name ),
42+ query : (q ) =>
43+ q .from ({ c: getCatalogCollection (scope ) }).orderBy (({ c }) => c .name ),
4344 ssr: { serializes: true },
4445 }),
4546)
@@ -48,7 +49,8 @@ export const getAccountSummaryLiveQuery = defineLiveQuery(
4849 ({ userId }: { userId: string }, scope : DbScope ) =>
4950 liveQueryCollectionOptions ({
5051 id: ` account-summary:${userId } ` ,
51- query : (q ) => q .from ({ a: getAccountCollection ({ userId }, scope ) }).findOne (),
52+ query : (q ) =>
53+ q .from ({ a: getAccountCollection ({ userId }, scope ) }).findOne (),
5254 ssr: { serializes: true },
5355 }),
5456 { scope: ' required' },
@@ -104,13 +106,15 @@ TanStack Start calls `createRouter()` per server request, so `dbScope` is reques
104106// src/start/middleware/db-scope.ts
105107import { createMiddleware } from ' @tanstack/start'
106108
107- export const dbScopeMiddleware = createMiddleware ().server (async ({ next , context }) => {
108- try {
109- return await next ()
110- } finally {
111- await context .dbScope .cleanup ()
112- }
113- })
109+ export const dbScopeMiddleware = createMiddleware ().server (
110+ async ({ next , context }) => {
111+ try {
112+ return await next ()
113+ } finally {
114+ await context .dbScope .cleanup ()
115+ }
116+ },
117+ )
114118```
115119
116120Cleanup runs after the full response lifecycle, not inside individual loaders.
0 commit comments