This repository was archived by the owner on Sep 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ test('Create an instance', t => {
3131 'getProviderAuthenticationUrl' ,
3232 'authenticateProvider' ,
3333 'getEntries' ,
34+ 'getEntryCount' ,
3435 'getEntry' ,
3536 'createEntry' ,
3637 'updateEntry' ,
@@ -349,6 +350,22 @@ test('Get entries', async t => {
349350 ) ;
350351} ) ;
351352
353+ test ( 'Get entry count' , async t => {
354+ await t . context . strapi . getEntryCount ( 'user' , {
355+ name_contains : 'jack'
356+ } ) ;
357+
358+ t . true (
359+ t . context . axiosRequest . calledWithExactly ( {
360+ method : 'get' ,
361+ params : {
362+ name_contains : 'jack'
363+ } ,
364+ url : '/user/count'
365+ } )
366+ ) ;
367+ } ) ;
368+
352369test ( 'Get entry' , async t => {
353370 await t . context . strapi . getEntry ( 'user' , 'ID' ) ;
354371
Original file line number Diff line number Diff line change @@ -241,6 +241,20 @@ export default class Strapi {
241241 } ) ;
242242 }
243243
244+ /**
245+ * Get the total count of entries with the provided criteria
246+ * @param contentType
247+ * @param params Filter and order queries.
248+ */
249+ public getEntryCount (
250+ contentType : string ,
251+ params ?: AxiosRequestConfig [ 'params' ]
252+ ) : Promise < object [ ] > {
253+ return this . request ( 'get' , `/${ contentType } /count` , {
254+ params
255+ } ) ;
256+ }
257+
244258 /**
245259 * Get a specific entry
246260 * @param contentType Type of entry
You can’t perform that action at this time.
0 commit comments