File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " apollo-mongodb-datasource" ,
3- "version" : " 1.3.2 " ,
3+ "version" : " 1.3.3 " ,
44 "description" : " An Apollo GraphQL Datasource using MongoDB." ,
55 "main" : " lib/index.js" ,
66 "types" : " lib/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -67,7 +67,10 @@ export default abstract class MongoDataSource<
6767 this . context = context ;
6868 }
6969
70- async count ( query : Filter < TSchema > = { } , options = { ttl : this . defaultTTL } ) {
70+ async count (
71+ query : Filter < TSchema > = { } ,
72+ options = { ttl : this . defaultTTL }
73+ ) : Promise < number > {
7174 const cacheKey = this . getCacheKey ( "count" , query ) ,
7275 cacheDoc = await this . cache ?. get ( cacheKey ) ;
7376 if ( cacheDoc ) return JSON . parse ( cacheDoc ) ;
@@ -105,9 +108,9 @@ export default abstract class MongoDataSource<
105108
106109 const docs = await this . antiSpam ( cacheKey , async ( ) => {
107110 const cursor = this . collection . find ( fields , options . findOptions ) ;
108- if ( sort ) cursor . sort ( sort . sort , sort . direction ) ;
109- if ( skip ) cursor . skip ( skip ) ;
110- if ( limit ) cursor . limit ( limit ) ;
111+ if ( sort !== undefined ) cursor . sort ( sort . sort , sort . direction ) ;
112+ if ( skip !== undefined ) cursor . skip ( skip ) ;
113+ if ( limit !== undefined ) cursor . limit ( limit ) ;
111114 const r = await cursor . toArray ( ) ;
112115 await this . cache ?. set ( cacheKey , JSON . stringify ( r ) , options ) ;
113116
You can’t perform that action at this time.
0 commit comments