Skip to main content
Version: v10.0.0

UpdateMutation


Import
import { UpdateMutation } from "@hyper-fetch/db"

Preview​

type UpdateMutation<Row,KeyField,Req,Mapped,Success> = {
map: (key: NonNullable<Row[KeyField]>, changes: Partial<Row>, context: MutationContext) => RequestPatch<Req>;
onSuccess?: Success & MutationSuccessMode;
optimistic?: boolean;
outbox?: boolean;
request: Req;
row?: (response: ExtractResponseType<Req>) => Mapped;
}

Structure​

UpdateMutation
NameTypeDescription
onSuccess
Success & MutationSuccessMode

Needed when the response is not the row or its changed fields with the key

optimistic
boolean

false when the backend applies writes locally on its own, such as Firestore, so the db adds no optimistic layer

outbox
boolean

false when the backend queues writes offline on its own, such as Firestore, so they skip the outbox

request
Req
map
(key: NonNullable<Row[KeyField]>, changes: Partial<Row>, context: MutationContext) => RequestPatch<Req>
row
(response: ExtractResponseType<Req>) => Mapped

Reads the key and changed fields from the response