Skip to content

Commit 171f776

Browse files
committed
chore: comments
1 parent 842484c commit 171f776

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/collection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ export class Collection<TSchema extends Document = Document> {
557557
const { batchSize: _batchSize, noCursorTimeout: _noCursorTimeout, ...opts } = options;
558558
opts.singleBatch = true;
559559
const cursor = this.find(filter, opts).limit(1);
560-
return await cursor.next();
560+
const result = await cursor.next();
561+
await cursor.close();
562+
return result;
561563
}
562564

563565
/**

src/operations/find.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,7 @@ function makeFindCommand(ns: MongoDBNamespace, filter: Document, options: FindOp
195195

196196
if (typeof options.batchSize === 'number') {
197197
if (options.batchSize < 0) {
198-
if (
199-
options.limit &&
200-
options.limit !== 0 &&
201-
Math.abs(options.batchSize) < Math.abs(options.limit)
202-
) {
203-
findCommand.limit = -options.batchSize;
204-
}
198+
findCommand.limit = -options.batchSize;
205199
} else {
206200
if (options.batchSize === options.limit) {
207201
// Spec dictates that if these are equal the batchSize should be one more than the

0 commit comments

Comments
 (0)