(id: string)
| 29 | } |
| 30 | |
| 31 | function 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 | |
| 75 | function recordBatches(collection: any) { |
| 76 | const batches: Array<Array<ChangeMessageLike>> = [] |
no test coverage detected
searching dependent graphs…