Replies: 1 comment
-
|
Optimistic inserts must take the type of the collection as they'll immediately render so the input must equal the output. If you want a mutator with a different type — I suggest using an action — see https://tanstack.com/db/latest/docs/guides/schemas & https://tanstack.com/db/latest/docs/guides/mutations#creating-custom-actions |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to use a different schema for handlers?
Currently, the
onInserthandler is typed to take in the same schema params as what the queryFun returns.In the example below, the
usersCollectionreturns an array of users withid,first_name,last_nameandemail.When inserting into the collection, using
usersCollection.insert(), the params are identical to the data being returned. But it should be typed as what my actual DB operation requires, in this case:I've been through the docs but haven't found a way to retype the inputs for collection handlers. Is this not currently supported?
Below is a full example:
Beta Was this translation helpful? Give feedback.
All reactions