postgrestx-monorepo / tanstack/src / createMutationFns
Function: createMutationFns()
createMutationFns(
client
):object
Defined in: packages/tanstack/src/index.ts:134
Factory for building reusable mutation functions wrapping PostgREST operations.
When / Why:
- Centralize mutation options (e.g. always request representation, logging).
- Build domain-level abstractions (e.g.
mutations.insertUser
). - Avoid recreating inline mutation functions inside components.
Parameters
client
Returns
object
insert()
insert<
T
>(resource
,options?
): (body
) =>Promise
<T
>
Type Parameters
T
T
= unknown
Parameters
resource
string
options?
Returns
(
body
):Promise
<T
>
Parameters
body
unknown
Returns
Promise
<T
>
update()
update<
T
>(resource
,options?
): (body
) =>Promise
<T
>
Type Parameters
T
T
= unknown
Parameters
resource
string
options?
Returns
(
body
):Promise
<T
>
Parameters
body
unknown
Returns
Promise
<T
>
upsert()
upsert<
T
>(resource
,options?
): (body
) =>Promise
<T
>
Type Parameters
T
T
= unknown
Parameters
resource
string
options?
Returns
(
body
):Promise
<T
>
Parameters
body
unknown
Returns
Promise
<T
>
delete()
delete<
T
>(resource
,options?
): () =>Promise
<T
>
Type Parameters
T
T
= unknown
Parameters
resource
string
options?
Returns
():
Promise
<T
>
Returns
Promise
<T
>
rpc()
rpc<
T
>(fnName
,args?
,options?
): () =>Promise
<T
>
Type Parameters
T
T
= unknown
Parameters
fnName
string
args?
Record
<string
, unknown
>
options?
QueryOptions
& object
Returns
():
Promise
<T
>
Returns
Promise
<T
>
Example
const { insert } = createMutationFns(client)
const addUser = useMutation({ mutationFn: insert<User>('users') })