Skip to content

OperationsFn

OperationsFn<TInput, TResult, TUser> = (db, input, ctx) => Operation<TResult>

Defined in: packages/actions/src/types.ts:107

A function that builds a database Operation for an action.

Receives the Drizzle database, the parsed input, and the full ActionContext. Returns an Operation (from @cfast/db) that encapsulates both the query/mutation and its permission descriptors.

TInput

The expected input shape for this action.

TResult

The return type of the operation.

TUser

The shape of the authenticated user object.

Db

TInput

ActionContext<TUser>

Operation<TResult>

const deletePostOps: OperationsFn<{ postId: string }, Response, AppUser> =
(db, input, ctx) =>
compose(
[db.delete(posts).where(eq(posts.id, input.postId))],
async (runDelete) => {
await runDelete({});
return redirect("/");
},
);