Skip to main content
Version: 0.24

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.

Use reference imports when passing values from your app into the Wasp spec. If a direct import is not practical, use ref as a fallback.

Returns

Crud

Example

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

crud('tasks', 'Task', {
getAll: { isPublic: true },
get: {},
create: { overrideFn: createTaskOverride },
update: {},
})