MCPcopy Index your code
hub / github.com/TanStack/db / setupLiveQueryCollections

Function setupLiveQueryCollections

packages/db/tests/query/scheduler.test.ts:31–73  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

29}
30
31function setupLiveQueryCollections(id: string) {
32 const users = createCollection<User>({
33 id: `${id}-users`,
34 getKey: (user) => user.id,
35 startSync: true,
36 sync: {
37 sync: ({ begin, commit, markReady }) => {
38 begin()
39 commit()
40 markReady()
41 },
42 },
43 })
44
45 const tasks = createCollection<Task>({
46 id: `${id}-tasks`,
47 getKey: (task) => task.id,
48 startSync: true,
49 sync: {
50 sync: ({ begin, commit, markReady }) => {
51 begin()
52 commit()
53 markReady()
54 },
55 },
56 })
57
58 const assignments = createLiveQueryCollection({
59 id: `${id}-assignments`,
60 startSync: true,
61 query: (q) =>
62 q
63 .from({ user: users })
64 .join({ task: tasks }, ({ user, task }) => eq(user.id, task.userId))
65 .select(({ user, task }) => ({
66 userId: user.id,
67 taskId: task.id,
68 title: task.title,
69 })),
70 })
71
72 return { users, tasks, assignments }
73}
74
75function recordBatches(collection: any) {
76 const batches: Array<Array<ChangeMessageLike>> = []

Callers 1

scheduler.test.tsFile · 0.85

Calls 6

createCollectionFunction · 0.85
selectMethod · 0.80
fromMethod · 0.80
eqFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…