# Query Engine API: Bulk Operations
✋ CAUTION
To avoid performance issues, bulk operations are not allowed on relations.
# createMany()
Creates multiple entries.
Syntax: createMany(parameters) => { count: number }
# Parameters
Parameter | Type | Description |
---|---|---|
data | Array of objects | Array of input data |
# Example
await strapi.db.query('api::blog.article').createMany({
data: [
{
title: 'ABCD',
},
{
title: 'EFGH',
},
],
});
// { count: 2 }
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# updateMany()
Updates multiple entries matching the parameters.
Syntax: updateMany(parameters) => { count: number }
# Parameters
Parameter | Type | Description |
---|---|---|
where | WhereParameter | Filters to use |
data | Object | Input data |
# Example
await strapi.db.query('api::shop.article').updateMany({
where: {
price: 20,
},
data: {
price: 18,
},
});
// { count: 42 }
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# deleteMany()
Deletes multiple entries matching the parameters.
Syntax: deleteMany(parameters) => { count: number }
# Parameters
Parameter | Type | Description |
---|---|---|
where | WhereParameter | Filters to use |
# Example
await strapi.db.query('api::blog.article').deleteMany({
where: {
title: {
$startsWith: 'v3',
},
},
});
// { count: 42 }
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# Aggregations
# count()
Counts entries matching the parameters.
Syntax: count(parameters) => number
# Parameters
Parameter | Type | Description |
---|---|---|
where | WhereParameter | Filters to use |
const count = await strapi.db.query('api::blog.article').count({
where: {
title: {
$startsWith: 'v3',
},
},
});
// 12
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9