# Query Engine API: Ordering & Paginating
The Query Engine API offers the ability to order and paginate results.
# Ordering
To order results returned by the Query Engine, use the orderBy
parameter. Results can be ordered based on a single or on multiple attributes and can also use relational ordering.
# Single
strapi.db.query('api::article.article').findMany({
orderBy: 'id',
});
// single with direction
strapi.db.query('api::article.article').findMany({
orderBy: { id: 'asc' },
});
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# Multiple
strapi.db.query('api::article.article').findMany({
orderBy: ['id', 'name'],
});
// multiple with direction
strapi.db.query('api::article.article').findMany({
orderBy: [{ title: 'asc' }, { publishedAt: 'desc' }],
});
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# Relational ordering
strapi.db.query('api::article.article').findMany({
orderBy: {
author: {
name: 'asc',
},
},
});
1
2
3
4
5
6
7
2
3
4
5
6
7
# Pagination
To paginate results returned by the Query Engine API, use the offset
and limit
parameters:
strapi.db.query('api::article.article').findMany({
offset: 15,
limit: 10,
});
1
2
3
4
2
3
4