@@ -784,7 +784,7 @@ The steps are to:
784
784
785
785
` ` ` tsx
786
786
import { useLiveQuery, createCollection } from "@tanstack/react-db"
787
- import { queryCollectionOptions } from "@tanstack/electric -db-collection"
787
+ import { queryCollectionOptions } from "@tanstack/query -db-collection"
788
788
789
789
// Load data into collections using TanStack Query.
790
790
// It's common to define these in a ` collections ` module.
@@ -793,7 +793,7 @@ const todoCollection = createCollection(queryCollectionOptions({
793
793
queryFn: async () => fetch("/api/todos"),
794
794
getKey: (item) => item.id,
795
795
schema: todoSchema, // any standard schema
796
- onInsert: ({ transaction }) => {
796
+ onInsert: async ({ transaction }) => {
797
797
const { changes: newTodo } = transaction.mutations[0]
798
798
799
799
// Handle the local write by sending it to your API.
@@ -805,8 +805,8 @@ const listCollection = createCollection(queryCollectionOptions({
805
805
queryKey: ["todo-lists"],
806
806
queryFn: async () => fetch("/api/todo-lists"),
807
807
getKey: (item) => item.id,
808
- schema: todoListSchema
809
- onInsert: ({ transaction }) => {
808
+ schema: todoListSchema,
809
+ onInsert: async ({ transaction }) => {
810
810
const { changes: newTodo } = transaction.mutations[0]
811
811
812
812
// Handle the local write by sending it to your API.
@@ -865,8 +865,8 @@ export const todoCollection = createCollection(electricCollectionOptions({
865
865
}
866
866
},
867
867
getKey: (item) => item.id,
868
- schema: todoSchema
869
- onInsert: ({ transaction }) => {
868
+ schema: todoSchema,
869
+ onInsert: async ({ transaction }) => {
870
870
const response = await api.todos.create(transaction.mutations[0].modified)
871
871
872
872
return { txid: response.txid}
0 commit comments