@@ -92,12 +92,20 @@ export default ({ strapi }) => ({
9292 *
9393 * @returns {Promise<number> } number of entries in the content type.
9494 */
95- numberOfEntries : async function ( { contentType, where = { } } ) {
95+ numberOfEntries : async function ( {
96+ contentType,
97+ filters = { } ,
98+ status = 'published' ,
99+ } ) {
96100 const contentTypeUid = this . getContentTypeUid ( { contentType } )
97101 if ( contentTypeUid === undefined ) return 0
98102
99103 try {
100- const count = await strapi . db . query ( contentTypeUid ) . count ( { where } )
104+ const count = await strapi . documents ( contentTypeUid ) . count ( {
105+ filters,
106+ status,
107+ } )
108+
101109 return count
102110 } catch ( e ) {
103111 strapi . log . warn ( e )
@@ -114,10 +122,14 @@ export default ({ strapi }) => ({
114122 *
115123 * @returns {Promise<number> } Total entries number of the content types.
116124 */
117- totalNumberOfEntries : async function ( { contentTypes, where = { } } ) {
125+ totalNumberOfEntries : async function ( {
126+ contentTypes,
127+ filters = { } ,
128+ status = 'published' ,
129+ } ) {
118130 let numberOfEntries = await Promise . all (
119131 contentTypes . map ( async contentType =>
120- this . numberOfEntries ( { contentType, where } ) ,
132+ this . numberOfEntries ( { contentType, filters , status } ) ,
121133 ) ,
122134 )
123135 const entriesSum = numberOfEntries . reduce ( ( acc , curr ) => ( acc += curr ) , 0 )
@@ -232,6 +244,7 @@ export default ({ strapi }) => ({
232244 // Need total number of entries in contentType
233245 const entries_count = await this . numberOfEntries ( {
234246 contentType,
247+ ...entriesQuery ,
235248 } )
236249 const cbResponse = [ ]
237250 for ( let index = 0 ; index < entries_count ; index += batchSize ) {
0 commit comments