It would be great if we had a way to enforce only being able to use mutations like someCollection.insert inside of actions.
e.g.
This is allowed
const addTodo = createOptimisticAction<string>({
onMutate: (text) => {
todoCollection.insert({
id: uuid(),
text,
completed: false
})
},
....
})
This should be forbidden
<Button onClick={() =>
todoCollection.insert({
id: uuid(),
text,
completed: false
})}>
</Button
Why
The more I have used Tanstack DB the more I have realized almost all mutations I do have some sort of side effects, making single mutations quite useless. I started only using optimistic actions but coding agents and teammates often fall into the trap on using inline muations again. a way to enforce to enforce mutations through actions would be great