onInsert vs createOptimisticAction
The docs don't make it clear when I can simply use an
onInsert
callback on my collection and just insert new elements vs when I need to use createOptimisticAction
.
Right now I have both defined and it's just duplicated code and I feel like I'm doing something wrong.
I do want optimistic updates, but I don't understand why there is a createOptimisticAction
when the onInsert
seems to do the same thing?3 Replies
xenial-blackOP•4w ago
For context this is what I have right now
continuing-cyan•4w ago
createOptimisticAction
is for when you need to optimistically mutate multiple collections within the same transaction. For example if you have a backend api to create and add a tag to a blog post, you likely need to mutate both a tags and postTags (many to many) collection within the same transaction.xenial-blackOP•4w ago
oooh that makes a ton of sense
thanks