Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ Collection.prototype.find = deprecateOptions(
}

// Translate to new command option noCursorTimeout
if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = newOptions.timeout;
if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = !newOptions.timeout;

decorateCommand(findCommand, newOptions, ['session', 'collation']);

Expand Down
16 changes: 10 additions & 6 deletions test/functional/find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,19 +1195,23 @@ describe('Find', function() {

// The actual test we wish to run
test: function(done) {
var configuration = this.configuration;
var client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 });
const configuration = this.configuration;
const client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 });
client.connect(function(err, client) {
var db = client.db(configuration.db);
const db = client.db(configuration.db);
db.createCollection('timeoutFalse', function(err, collection) {
expect(err).to.not.exist;
collection.find({}, { timeout: false }, function(err, cursor) {
test.equal(false, cursor.cmd.noCursorTimeout);
expect(err).to.not.exist;
expect(cursor.cmd.noCursorTimeout).to.be.true;

collection.find({}, { timeout: true }, function(err, cursor) {
test.equal(true, cursor.cmd.noCursorTimeout);
expect(err).to.not.exist;
expect(cursor.cmd.noCursorTimeout).to.be.false;

collection.find({}, {}, function(err, cursor) {
test.ok(!cursor.cmd.noCursorTimeout);
expect(err).to.not.exist;
expect(cursor.cmd.noCursorTimeout).to.not.exist;

client.close(done);
});
Expand Down