Skip to content

Commit bc4ef79

Browse files
committed
Add pagination
1 parent aa562ee commit bc4ef79

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

server/services/lifecycle/lifecycle.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,24 @@ module.exports = ({ strapi }) => {
7777
.plugin('meilisearch')
7878
.service('meilisearch')
7979

80-
const entries = await contentTypeService.getEntries({
80+
const nbrEntries = await contentTypeService.numberOfEntries({
8181
contentType: contentTypeUid,
82-
filters: event.params.where,
82+
where: event.params.where,
8383
})
8484

85+
const entries = []
86+
const BATCH_SIZE = 500
87+
88+
for (let pos = 0; pos < nbrEntries; pos += BATCH_SIZE) {
89+
const batch = await contentTypeService.getEntries({
90+
contentType: contentTypeUid,
91+
filters: event.params.where,
92+
start: pos,
93+
limit: BATCH_SIZE,
94+
})
95+
entries.push(...batch)
96+
}
97+
8598
meilisearch
8699
.updateEntriesInMeilisearch({
87100
contentType: contentTypeUid,

0 commit comments

Comments
 (0)