# Single Operations

> Source: https://docs.strapi.io/cms/api/query-engine/single-operations

The Query Engine API provides methods to find, create, update, and delete individual entries with filtering, selection, pagination, and relation population options.

:::caution
In most cases you should not use the Query Engine API and rather use the [Document Service API](/cms/api/document-service).

Only use the Query Engine API if you exactly know what you are doing, for instance if you want to use a lower-level API that directly interacts with unique rows of the database.

Please keep in mind that the Query Engine API is not aware of the most advanced Strapi 5 features like Draft & Publish, Internationalization, Content History, and possibly more.
This also means that the Query Engine API will not be able to use `documentId` and will use `id`, which means it could lead to unattended consequences at the database level or partial or incomplete compatibility with Strapi 5 features. 
:::

:::prerequisites
Before diving deeper into the Query Engine API documentation, it is recommended that you read the following introductions:
- the [backend customization introduction](/cms/backend-customization),
- and the [Content APIs introduction](/cms/api/content-api).
:::

## findOne()

:::note
 Only use the Query Engine's `findOne()` method if the [Document Service's `findOne()`](/cms/api/document-service#findone) method can't cover your use case.
:::
Finds the first entry matching the parameters.

Syntax: `findOne(parameters) ⇒ Entry`

### Parameters

| Parameter  | Type   | Description   |
| ---------- | -------------- | --------- |
| `select`   | String, or Array of strings | [Attributes](/cms/backend-customization/models#model-attributes) to return |
| `where`    | [`WhereParameter`](/cms/api/query-engine/filtering/) | [Filters](/cms/api/query-engine/filtering/) to use   |
| `offset`   | Integer   | Number of entries to skip   |
| `orderBy`  | [`OrderByParameter`](/cms/api/query-engine/order-pagination/) | [Order](/cms/api/query-engine/order-pagination/) definition |
| `populate` | [`PopulateParameter`](/cms/api/query-engine/populating/) | Relations to [populate](/cms/api/query-engine/populating/) |

### Example

```js
const entry = await strapi.db.query('api::blog.article').findOne({
  select: ['title', 'description'],
  where: { title: 'Hello World' },
  populate: { category: true },
});
```

## findMany()

:::note
 Only use the Query Engine's `findMany()` method if the [Document Service `findMany()`](/cms/api/document-service#findmany) method can't cover your use case.
:::

Finds entries matching the parameters.

Syntax: `findMany(parameters) ⇒ Entry[]`

### Parameters

| Parameter | Type                           | Description                                |
| --------- | ------------------------------ | ------------------------------------------ |
| `select`   | String, or Array of strings | [Attributes](/cms/backend-customization/models#model-attributes) to return |
| `where`    | [`WhereParameter`](/cms/api/query-engine/filtering/)  | [Filters](/cms/api/query-engine/filtering/) to use |
| `limit`   | Integer  | Number of entries to return  |
| `offset`   | Integer  | Number of entries to skip |
| `orderBy`  | [`OrderByParameter`](/cms/api/query-engine/order-pagination/) | [Order](/cms/api/query-engine/order-pagination/) definition |
| `populate` | [`PopulateParameter`](/cms/api/query-engine/populating/)      | Relations to [populate](/cms/api/query-engine/populating/) |

### Example

```js
const entries = await strapi.db.query('api::blog.article').findMany({
  select: ['title', 'description'],
  where: { title: 'Hello World' },
  orderBy: { publishedAt: 'DESC' },
  populate: { category: true },
});
```

## findWithCount()

Finds and counts entries matching the parameters.

Syntax: `findWithCount(parameters) => [Entry[], number]`

### Parameters

| Parameter | Type                           | Description                                |
| --------- | ------------------------------ | ------------------------------------------ |
| `select`   | String, or Array of strings | [Attributes](/cms/backend-customization/models#model-attributes) to return |
| `where`    | [`WhereParameter`](/cms/api/query-engine/filtering/)          | [Filters](/cms/api/query-engine/filtering/) to use |
| `limit`     | Integer    | Number of entries to return    |
| `offset`   | Integer  | Number of entries to skip  |
| `orderBy`  | [`OrderByParameter`](/cms/api/query-engine/order-pagination/) | [Order](/cms/api/query-engine/order-pagination/) definition |
| `populate` | [`PopulateParameter`](/cms/api/query-engine/populating/)      | Relations to [populate](/cms/api/query-engine/populating/) |

### Example

```js
const [entries, count] = await strapi.db.query('api::blog.article').findWithCount({
  select: ['title', 'description'],
  where: { title: 'Hello World' },
  orderBy: { title: 'DESC' },
  populate: { category: true },
});
```

## create()

:::note
 Only use the Query Engine's `create()` method if the [Document Service `create()` method](/cms/api/document-service#create) can't cover your use case.
:::

Creates one entry and returns it.

Syntax: `create(parameters) => Entry`

### Parameters

| Parameter | Type                           | Description                                |
| --------- | ------------------------------ | ------------------------------------------ |
| `select`   | String, or Array of strings | [Attributes](/cms/backend-customization/models#model-attributes) to return |
| `populate` | [`PopulateParameter`](/cms/api/query-engine/populating/)  | Relations to [populate](/cms/api/query-engine/populating/) |
| `data`  | Object   | Input data  |

### Example

```js
const entry = await strapi.db.query('api::blog.article').create({
  data: {
    title: 'My Article',
  },
});
```

## update()

:::note
 Only use the Query Engine's `update()` method if the [Document Service `update()`](/cms/api/document-service#update) method can't cover your use case.
:::

Updates one entry and returns it.

Syntax: `update(parameters) => Entry`

### Parameters

| Parameter | Type                           | Description                                |
| --------- | ------------------------------ | ------------------------------------------ |
| `select`   | String, or Array of strings | [Attributes](/cms/backend-customization/models#model-attributes) to return |
| `populate` | [`PopulateParameter`](/cms/api/query-engine/populating/)      | Relations to [populate](/cms/api/query-engine/populating/)
| `where`    | [`WhereParameter`](/cms/api/query-engine/filtering/)          | [Filters](/cms/api/query-engine/filtering/) to use  |
| `data`  | Object     | Input data   |

### Example

```js
const entry = await strapi.db.query('api::blog.article').update({
  where: { id: 1 },
  data: {
    title: 'xxx',
  },
});
```

## delete()

:::note
 Only use the Query Engine's `delete()` method if the [Document Service `delete()`](/cms/api/document-service#delete) method can't cover your use case.
:::

Deletes one entry and returns it.

Syntax: `delete(parameters) => Entry`

### Parameters

| Parameter | Type                           | Description                                |
| --------- | ------------------------------ | ------------------------------------------ |
| `select`   | String, or Array of strings | [Attributes](/cms/backend-customization/models#model-attributes) to return |
| `populate` | [`PopulateParameter`](/cms/api/query-engine/populating/)      | Relations to [populate](/cms/api/query-engine/populating/)
| `where`    | [`WhereParameter`](/cms/api/query-engine/filtering/)          | [Filters](/cms/api/query-engine/filtering/) to use    |

### Example

```js
const entry = await strapi.db.query('api::blog.article').delete({
  where: { id: 1 },
});
```
