Skip to main content
Version: Next

Function: crud()

crud(name, entity, operations): Crud

Creates a Crud definition.

Auto-generates queries and actions for a Prisma entity. Each operation in operations can be enabled with defaults (an empty object), made public via isPublic, or replaced by a custom implementation via overrideFn.

See Automatic CRUD.

Parameters

name

string

Unique name for the generated CRUD.

entity

string

Name of the Prisma entity to generate operations for.

operations

CrudOperations

Which operations to generate and how to configure each.

Returns

Crud

Example

import { crud } from '@wasp.sh/spec'
import { createTaskOverride } from './src/actions' with { type: 'ref' }

crud('tasks', 'Task', {
getAll: {},
create: { overrideFn: createTaskOverride },
})