本页还没有译文
本页 18 段还没译成日本語,下面显示的是英文原文。LocalOnlyCollectionUtils
还没翻译译自英文(tanstack.com)本页 18 段都还没译
Defined in: packages/db/src/local-only.ts:42
Local-only collection utilities type
Extends
Indexable
[key: string]: anyProperties
acceptMutations()
acceptMutations: (transaction) => void;Defined in: packages/db/src/local-only.ts:60
Accepts mutations from a transaction that belong to this collection and persists them. This should be called in your transaction's mutationFn to persist local-only data.
Parameters
transaction
The transaction containing mutations to accept
mutations
PendingMutation<Record<string, unknown>, OperationType, Collection<Record<string, unknown>, any, any, any, any>>[]
Returns
void
Example
const localData = createCollection(localOnlyCollectionOptions({...}))
const tx = createTransaction({
mutationFn: async ({ transaction }) => {
// Make API call first
await api.save(...)
// Then persist local-only mutations after success
localData.utils.acceptMutations(transaction)
}
})AI 翻译查看英文原文