Skip to content

Commit 5d38923

Browse files
committed
🐛 small fixes
1 parent 82961ab commit 5d38923

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)