Skip to content

Commit 2edf2a2

Browse files
author
Divjot Arora
committed
Set limit to -1 for Collection.FindOne
GODRIVER-1112 Change-Id: I9f7b5b9c4a49bb54099b47422b605073f9790540
1 parent 5da0272 commit 2edf2a2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mongo/collection.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,9 @@ func (coll *Collection) FindOne(ctx context.Context, filter interface{},
991991
Sort: opt.Sort,
992992
}
993993
}
994+
// Unconditionally send a limit to make sure only one document is returned and the cursor is not kept open
995+
// by the server.
996+
findOpts = append(findOpts, options.Find().SetLimit(-1))
994997

995998
batchCursor, err := driver.Find(
996999
ctx, cmd,

0 commit comments

Comments
 (0)