Skip to main content
Version: v10.0.0

InsertMutation


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

Preview​

type InsertMutation<Row,Req,Mapped,Success> = {
map: (row: Row, context: MutationContext) => RequestPatch<Req>;
onSuccess?: Success & MutationSuccessMode;
optimistic?: boolean;
outbox?: boolean;
request: Req;
row?: (response: ExtractResponseType<Req>) => Mapped;
}

Structure​

InsertMutation
NameTypeDescription
onSuccess
Success & MutationSuccessMode

Needed when the response is not the row

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
(row: Row, context: MutationContext) => RequestPatch<Req>
row
(response: ExtractResponseType<Req>) => Mapped

Reads the inserted row from the response