> ## Documentation Index
> Fetch the complete documentation index at: https://nestjs-query.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Mutations

> The generated controller provides create, update, and delete endpoints for a single record. Mutation bodies are ordinary JSON and are described in OpenAPI using the configured create and update DTOs.

## Create one[​](#create-one "Direct link to Create one")

```http theme={null}
POST /todo-items
Content-Type: application/json
{
  "title": "Write REST documentation",
  "completed": false
}
```

A successful create returns `201 Created` with the serialized record.

```json theme={null}
{
  "id": 1,
  "title": "Write REST documentation",
  "completed": false
}
```

## Update one[​](#update-one "Direct link to Update one")

```http theme={null}
PUT /todo-items/1
Content-Type: application/json
{
  "completed": true
}
```

A successful update returns `200 OK` with the updated record. Make update DTO properties nullable/optional so clients can submit partial updates.

## Delete one[​](#delete-one "Direct link to Delete one")

```http theme={null}
DELETE /todo-items/1
```

A successful delete returns `200 OK` with the deleted record data supplied by the query service.

Set `useSoftDelete: true` when the persistence adapter and service support soft deletion:

```ts theme={null}
{
  DTOClass: TodoItemDTO,
  EntityClass: TodoItemEntity,
  delete: { useSoftDelete: true }
}
```

## Disable or customize mutations[​](#disable-or-customize-mutations "Direct link to Disable or customize mutations")

```ts theme={null}
{
  DTOClass: TodoItemDTO,
  EntityClass: TodoItemEntity,
  create: { disabled: true },
  update: {
    one: { path: ':id', guards: [EditorGuard] }
  },
  delete: {
    useSoftDelete: true,
    one: { path: ':id/archive', description: 'Archive a task' }
  }
}
```

You can also supply custom `CreateOneInput` or `UpdateOneInput` classes when the generated body type is not sufficient. For application-level transformations, use [hooks](/rest/hooks); for record-level access rules, use [authorization](/rest/authorization).

[Edit this page](https://github.com/tripss/nestjs-query/edit/master/docs/rest/mutations)
