Commit 4ba9a593 authored by Xavier Guimard's avatar Xavier Guimard

Update upstream source from tag 'upstream/3.2.7+_3.2.7'

Update to upstream version '3.2.7+~3.2.7'
with Debian dir fabeef4dcf20e1d9b2c67093a3109f295a369a11
parents 1dc573f1 bd2e47cb
......@@ -2,6 +2,73 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="3.2.7"></a>
## [3.2.7](https://github.com/mongodb/node-mongodb-native/compare/v3.2.6...v3.2.7) (2019-06-04)
### Bug Fixes
* **core:** updating core to version 3.2.7 ([2f91466](https://github.com/mongodb/node-mongodb-native/commit/2f91466))
* **findOneAndReplace:** throw error if atomic operators provided for findOneAndReplace ([6a860a3](https://github.com/mongodb/node-mongodb-native/commit/6a860a3))
<a name="3.2.6"></a>
## [3.2.6](https://github.com/mongodb/node-mongodb-native/compare/v3.2.5...v3.2.6) (2019-05-24)
<a name="3.2.5"></a>
## [3.2.5](https://github.com/mongodb/node-mongodb-native/compare/v3.2.4...v3.2.5) (2019-05-17)
### Bug Fixes
* **core:** updating core to 3.2.5 ([a2766c1](https://github.com/mongodb/node-mongodb-native/commit/a2766c1))
<a name="3.2.4"></a>
## [3.2.4](https://github.com/mongodb/node-mongodb-native/compare/v3.2.2...v3.2.4) (2019-05-08)
### Bug Fixes
* **aggregation:** fix field name typo ([4235d04](https://github.com/mongodb/node-mongodb-native/commit/4235d04))
* **async:** rewrote asyncGenerator in node < 10 syntax ([49c8cef](https://github.com/mongodb/node-mongodb-native/commit/49c8cef))
* **BulkOp:** run unordered bulk ops in serial ([f548bd7](https://github.com/mongodb/node-mongodb-native/commit/f548bd7))
* **bulkWrite:** fix issue with bulkWrite continuing w/ callback ([2a4a42c](https://github.com/mongodb/node-mongodb-native/commit/2a4a42c))
* **docs:** correctly document that default for `sslValidate` is false ([1f8e7fa](https://github.com/mongodb/node-mongodb-native/commit/1f8e7fa))
* **gridfs-stream:** honor chunk size ([9eeb114](https://github.com/mongodb/node-mongodb-native/commit/9eeb114))
* **unified-topology:** only clone pool size if provided ([8dc2416](https://github.com/mongodb/node-mongodb-native/commit/8dc2416))
### Features
* update to mongodb-core v3.2.3 ([1c5357a](https://github.com/mongodb/node-mongodb-native/commit/1c5357a))
* **core:** update to mongodb-core v3.2.4 ([2059260](https://github.com/mongodb/node-mongodb-native/commit/2059260))
* **lib:** implement executeOperationV2 ([67d4edf](https://github.com/mongodb/node-mongodb-native/commit/67d4edf))
<a name="3.2.3"></a>
## [3.2.3](https://github.com/mongodb/node-mongodb-native/compare/v3.2.2...v3.2.3) (2019-04-05)
### Bug Fixes
* **aggregation:** fix field name typo ([4235d04](https://github.com/mongodb/node-mongodb-native/commit/4235d04))
* **async:** rewrote asyncGenerator in node < 10 syntax ([49c8cef](https://github.com/mongodb/node-mongodb-native/commit/49c8cef))
* **bulkWrite:** fix issue with bulkWrite continuing w/ callback ([2a4a42c](https://github.com/mongodb/node-mongodb-native/commit/2a4a42c))
* **docs:** correctly document that default for `sslValidate` is false ([1f8e7fa](https://github.com/mongodb/node-mongodb-native/commit/1f8e7fa))
### Features
* update to mongodb-core v3.2.3 ([1c5357a](https://github.com/mongodb/node-mongodb-native/commit/1c5357a))
<a name="3.2.2"></a>
## [3.2.2](https://github.com/mongodb/node-mongodb-native/compare/v3.2.1...v3.2.2) (2019-03-22)
......
......@@ -31,10 +31,9 @@ case in our issue management tool, JIRA:
Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the
Core Server (i.e. SERVER) project are **public**.
### Questions and Bug Reports
### Support / Feedback
* Mailing List: [groups.google.com/forum/#!forum/node-mongodb-native](https://groups.google.com/forum/#!forum/node-mongodb-native)
* JIRA: [jira.mongodb.org](http://jira.mongodb.org)
For issues with, questions about, or feedback for the Node.js driver, please look into our [support channels](http://www.mongodb.org/about/support). Please do not email any of the driver developers directly with issues or questions - you're more likely to get an answer on the [mongodb-user](http://groups.google.com/group/mongodb-user>) list on Google Groups.
### Change Log
......
File added
......@@ -148,7 +148,7 @@ AggregationCursor.prototype.batchSize = function(value) {
if (this.s.state === AggregationCursor.CLOSED || this.isDead())
throw MongoError.create({ message: 'Cursor is closed', driver: true });
if (typeof value !== 'number')
throw MongoError.create({ message: 'batchSize requires an integer', drvier: true });
throw MongoError.create({ message: 'batchSize requires an integer', driver: true });
if (this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value;
this.setCursorBatchSize(value);
return this;
......@@ -326,7 +326,7 @@ AggregationCursor.prototype.get = AggregationCursor.prototype.toArray;
/**
* Returns an array of documents. The caller is responsible for making sure that there
* is enough memory to store the results. Note that the array only contain partial
* results when this cursor had been previouly accessed. In that case,
* results when this cursor had been previously accessed. In that case,
* cursor.rewind() can be used to reset the cursor.
* @method AggregationCursor.prototype.toArray
* @param {AggregationCursor~toArrayResultCallback} [callback] The result callback.
......@@ -343,7 +343,7 @@ AggregationCursor.prototype.get = AggregationCursor.prototype.toArray;
/**
* Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
* not all of the elements will be iterated if this cursor had been previouly accessed.
* not all of the elements will be iterated if this cursor had been previously accessed.
* In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike
* **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements
* at any given time if batch size is specified. Otherwise, the caller is responsible
......
'use strict';
async function* asyncIterator() {
while (true) {
const value = await this.next();
if (!value) {
await this.close();
return;
}
// async function* asyncIterator() {
// while (true) {
// const value = await this.next();
// if (!value) {
// await this.close();
// return;
// }
// yield value;
// }
// }
yield value;
}
// TODO: change this to the async generator function above
function asyncIterator() {
const cursor = this;
return {
next: function() {
return Promise.resolve()
.then(() => cursor.next())
.then(value => {
if (!value) {
return cursor.close().then(() => ({ value, done: true }));
}
return { value, done: false };
});
}
};
}
exports.asyncIterator = asyncIterator;
......@@ -2,18 +2,18 @@
const Long = require('mongodb-core').BSON.Long;
const MongoError = require('mongodb-core').MongoError;
const ObjectID = require('mongodb-core').BSON.ObjectID;
const BSON = require('mongodb-core').BSON;
const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError;
const toError = require('../utils').toError;
const handleCallback = require('../utils').handleCallback;
const applyRetryableWrites = require('../utils').applyRetryableWrites;
const applyWriteConcern = require('../utils').applyWriteConcern;
const ObjectID = require('mongodb-core').BSON.ObjectID;
const BSON = require('mongodb-core').BSON;
const executeOperation = require('../utils').executeOperation;
const isPromiseLike = require('../utils').isPromiseLike;
// Error codes
const UNKNOWN_ERROR = 8;
const INVALID_BSON_ERROR = 22;
const WRITE_CONCERN_ERROR = 64;
const MULTIPLE_ERROR = 65;
// Insert types
const INSERT = 1;
......@@ -54,18 +54,6 @@ class Batch {
}
}
/**
* Wraps a legacy operation so we can correctly rewrite it's error
* @ignore
*/
class LegacyOp {
constructor(batchType, operation, index) {
this.batchType = batchType;
this.index = index;
this.operation = operation;
}
}
/**
* Create a new BulkWriteResult instance (INTERNAL TYPE, do not instantiate directly)
*
......@@ -352,7 +340,7 @@ class WriteError {
* Merges results into shared data structure
* @ignore
*/
function mergeBatchResults(ordered, batch, bulkResult, err, result) {
function mergeBatchResults(batch, bulkResult, err, result) {
// If we have an error set the result to be the err object
if (err) {
result = err;
......@@ -484,6 +472,41 @@ function mergeBatchResults(ordered, batch, bulkResult, err, result) {
}
}
function executeCommands(bulkOperation, options, callback) {
if (bulkOperation.s.batches.length === 0) {
return handleCallback(callback, null, new BulkWriteResult(bulkOperation.s.bulkResult));
}
const batch = bulkOperation.s.batches.shift();
function resultHandler(err, result) {
// Error is a driver related error not a bulk op error, terminate
if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
return handleCallback(callback, err);
}
// If we have and error
if (err) err.ok = 0;
if (err instanceof MongoWriteConcernError) {
return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, err, callback);
}
// Merge the results together
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
const mergeResult = mergeBatchResults(batch, bulkOperation.s.bulkResult, err, result);
if (mergeResult != null) {
return handleCallback(callback, null, writeResult);
}
if (bulkOperation.handleWriteError(callback, writeResult)) return;
// Execute the next command in line
executeCommands(bulkOperation, options, callback);
}
bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
}
/**
* handles write concern error
*
......@@ -493,8 +516,8 @@ function mergeBatchResults(ordered, batch, bulkResult, err, result) {
* @param {WriteConcernError} err
* @param {function} callback
*/
function handleMongoWriteConcernError(batch, bulkResult, ordered, err, callback) {
mergeBatchResults(ordered, batch, bulkResult, null, err.result);
function handleMongoWriteConcernError(batch, bulkResult, err, callback) {
mergeBatchResults(batch, bulkResult, null, err.result);
const wrappedWriteConcernError = new WriteConcernError({
errmsg: err.result.writeConcernError.errmsg,
......@@ -906,6 +929,15 @@ class BulkOperationBase {
);
}
_handleEarlyError(err, callback) {
if (typeof callback === 'function') {
callback(err, null);
return;
}
return this.s.promiseLibrary.reject(err);
}
/**
* Execute next write command in a chain
*
......@@ -919,19 +951,17 @@ class BulkOperationBase {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
if (this.s.executed) {
const executedError = toError('batch cannot be re-executed');
return typeof callback === 'function'
? callback(executedError, null)
: this.s.promiseLibrary.reject(executedError);
}
if (typeof _writeConcern === 'function') {
callback = _writeConcern;
} else if (_writeConcern && typeof _writeConcern === 'object') {
this.s.writeConcern = _writeConcern;
}
if (this.s.executed) {
const executedError = toError('batch cannot be re-executed');
return this._handleEarlyError(executedError, callback);
}
// If we have current batch
if (this.isOrdered) {
if (this.s.currentBatch) this.s.batches.push(this.s.currentBatch);
......@@ -943,13 +973,43 @@ class BulkOperationBase {
// If we have no operations in the bulk raise an error
if (this.s.batches.length === 0) {
const emptyBatchError = toError('Invalid Operation, no operations specified');
return typeof callback === 'function'
? callback(emptyBatchError, null)
: this.s.promiseLibrary.reject(emptyBatchError);
return this._handleEarlyError(emptyBatchError, callback);
}
return { options, callback };
}
/**
* The callback format for results
* @callback BulkOperationBase~resultCallback
* @param {MongoError} error An error instance representing the error during the execution.
* @param {BulkWriteResult} result The bulk write result.
*/
/**
* Execute the ordered bulk operation
*
* @method
* @param {object} [options] Optional settings.
* @param {(number|string)} [options.w] The write concern.
* @param {number} [options.wtimeout] The write concern timeout.
* @param {boolean} [options.j=false] Specify a journal write concern.
* @param {boolean} [options.fsync=false] Specify a file sync write concern.
* @param {BulkOperationBase~resultCallback} [callback] The result callback
* @throws {MongoError} Throws error if the bulk object has already been executed
* @throws {MongoError} Throws error if the bulk object does not have any operations
* @return {Promise} returns Promise if no callback passed
*/
execute(_writeConcern, options, callback) {
const ret = this.bulkExecute(_writeConcern, options, callback);
if (!ret || isPromiseLike(ret)) {
return ret;
}
options = ret.options;
callback = ret.callback;
return executeOperation(this.s.topology, executeCommands, [this, options, callback]);
}
/**
* Handles final options before executing command
*
......@@ -1033,11 +1093,7 @@ class BulkOperationBase {
// Force top level error
err.ok = 0;
// Merge top level error and return
handleCallback(
callback,
null,
mergeBatchResults(false, config.batch, this.s.bulkResult, err, null)
);
handleCallback(callback, null, mergeBatchResults(config.batch, this.s.bulkResult, err, null));
}
}
......@@ -1094,20 +1150,8 @@ Object.defineProperty(BulkOperationBase.prototype, 'length', {
module.exports = {
Batch,
BulkOperationBase,
BulkWriteError,
BulkWriteResult,
bson,
FindOperators,
handleMongoWriteConcernError,
LegacyOp,
mergeBatchResults,
INVALID_BSON_ERROR: INVALID_BSON_ERROR,
MULTIPLE_ERROR: MULTIPLE_ERROR,
UNKNOWN_ERROR: UNKNOWN_ERROR,
WRITE_CONCERN_ERROR: WRITE_CONCERN_ERROR,
INSERT: INSERT,
UPDATE: UPDATE,
REMOVE: REMOVE,
WriteError,
WriteConcernError
REMOVE: REMOVE
};
......@@ -2,17 +2,10 @@
const common = require('./common');
const BulkOperationBase = common.BulkOperationBase;
const utils = require('../utils');
const toError = utils.toError;
const handleCallback = utils.handleCallback;
const BulkWriteResult = common.BulkWriteResult;
const Batch = common.Batch;
const mergeBatchResults = common.mergeBatchResults;
const executeOperation = utils.executeOperation;
const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError;
const handleMongoWriteConcernError = require('./common').handleMongoWriteConcernError;
const bson = common.bson;
const isPromiseLike = require('../utils').isPromiseLike;
const utils = require('../utils');
const toError = utils.toError;
/**
* Add to internal list of Operations
......@@ -85,6 +78,7 @@ function addToOperationsList(bulkOperation, docType, document) {
/**
* Create a new OrderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly)
* @class
* @extends BulkOperationBase
* @property {number} length Get the number of operations in the bulk.
* @return {OrderedBulkOperation} a OrderedBulkOperation instance.
*/
......@@ -96,81 +90,6 @@ class OrderedBulkOperation extends BulkOperationBase {
super(topology, collection, options, true);
}
/**
* The callback format for results
* @callback OrderedBulkOperation~resultCallback
* @param {MongoError} error An error instance representing the error during the execution.
* @param {BulkWriteResult} result The bulk write result.
*/
/**
* Execute the ordered bulk operation
*
* @method
* @param {object} [options] Optional settings.
* @param {(number|string)} [options.w] The write concern.
* @param {number} [options.wtimeout] The write concern timeout.
* @param {boolean} [options.j=false] Specify a journal write concern.
* @param {boolean} [options.fsync=false] Specify a file sync write concern.
* @param {OrderedBulkOperation~resultCallback} [callback] The result callback
* @throws {MongoError}
* @return {Promise} returns Promise if no callback passed
*/
execute(_writeConcern, options, callback) {
const ret = this.bulkExecute(_writeConcern, options, callback);
if (isPromiseLike(ret)) {
return ret;
}
options = ret.options;
callback = ret.callback;
return executeOperation(this.s.topology, executeCommands, [this, options, callback]);
}
}
/**
* Execute next write command in a chain
*
* @param {OrderedBulkOperation} bulkOperation
* @param {object} options
* @param {function} callback
*/
function executeCommands(bulkOperation, options, callback) {
if (bulkOperation.s.batches.length === 0) {
return handleCallback(callback, null, new BulkWriteResult(bulkOperation.s.bulkResult));
}
// Ordered execution of the command
const batch = bulkOperation.s.batches.shift();
function resultHandler(err, result) {
// Error is a driver related error not a bulk op error, terminate
if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
return handleCallback(callback, err);
}
// If we have and error
if (err) err.ok = 0;
if (err instanceof MongoWriteConcernError) {
return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, true, err, callback);
}
// Merge the results together
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
const mergeResult = mergeBatchResults(true, batch, bulkOperation.s.bulkResult, err, result);
if (mergeResult != null) {
return handleCallback(callback, null, writeResult);
}
if (bulkOperation.handleWriteError(callback, writeResult)) return;
// Execute the next command in line
executeCommands(bulkOperation, options, callback);
}
bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
}
/**
......
......@@ -2,17 +2,10 @@
const common = require('./common');
const BulkOperationBase = common.BulkOperationBase;
const utils = require('../utils');
const toError = utils.toError;
const handleCallback = utils.handleCallback;
const BulkWriteResult = common.BulkWriteResult;
const Batch = common.Batch;
const mergeBatchResults = common.mergeBatchResults;
const executeOperation = utils.executeOperation;
const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError;
const handleMongoWriteConcernError = require('./common').handleMongoWriteConcernError;
const bson = common.bson;
const isPromiseLike = require('../utils').isPromiseLike;
const utils = require('../utils');
const toError = utils.toError;
/**
* Add to internal list of Operations
......@@ -98,6 +91,7 @@ function addToOperationsList(bulkOperation, docType, document) {
/**
* Create a new UnorderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly)
* @class
* @extends BulkOperationBase
* @property {number} length Get the number of operations in the bulk.
* @return {UnorderedBulkOperation} a UnorderedBulkOperation instance.
*/
......@@ -108,106 +102,6 @@ class UnorderedBulkOperation extends BulkOperationBase {
super(topology, collection, options, false);
}
/**
* The callback format for results
* @callback UnorderedBulkOperation~resultCallback
* @param {MongoError} error An error instance representing the error during the execution.
* @param {BulkWriteResult} result The bulk write result.
*/
/**
* Execute the ordered bulk operation
*
* @method
* @param {object} [options] Optional settings.
* @param {(number|string)} [options.w] The write concern.
* @param {number} [options.wtimeout] The write concern timeout.
* @param {boolean} [options.j=false] Specify a journal write concern.
* @param {boolean} [options.fsync=false] Specify a file sync write concern.
* @param {UnorderedBulkOperation~resultCallback} [callback] The result callback
* @throws {MongoError}
* @return {Promise} returns Promise if no callback passed
*/
execute(_writeConcern, options, callback) {
const ret = this.bulkExecute(_writeConcern, options, callback);
if (isPromiseLike(ret)) {
return ret;
}
options = ret.options;
callback = ret.callback;
return executeOperation(this.s.topology, executeBatches, [this, options, callback]);
}
}
/**
* Execute the command
*
* @param {UnorderedBulkOperation} bulkOperation
* @param {object} batch
* @param {object} options
* @param {function} callback
*/
function executeBatch(bulkOperation, batch, options, callback) {
function resultHandler(err, result) {
// Error is a driver related error not a bulk op error, terminate
if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
return handleCallback(callback, err);
}
// If we have and error
if (err) err.ok = 0;
if (err instanceof MongoWriteConcernError) {
return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, false, err, callback);
}
handleCallback(
callback,
null,
mergeBatchResults(false, batch, bulkOperation.s.bulkResult, err, result)
);
}
bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
}
/**
* Execute all the commands
*
* @param {UnorderedBulkOperation} bulkOperation
* @param {object} options
* @param {function} callback
*/
function executeBatches(bulkOperation, options, callback) {
let numberOfCommandsToExecute = bulkOperation.s.batches.length;
let hasErrored = false;
// Execute over all the batches
for (let i = 0; i < bulkOperation.s.batches.length; i++) {
executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
if (hasErrored) {
return;
}
if (err) {
hasErrored = true;
return handleCallback(callback, err);
}
// Count down the number of commands left to execute
numberOfCommandsToExecute = numberOfCommandsToExecute - 1;
// Execute
if (numberOfCommandsToExecute === 0) {
// Driver level error
if (err) return handleCallback(callback, err);
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
if (bulkOperation.handleWriteError(callback, writeResult)) return;
return handleCallback(callback, null, writeResult);
}
});
}
}
/**
......
This diff is collapsed.
......@@ -259,7 +259,7 @@ CommandCursor.prototype.get = CommandCursor.prototype.toArray;
/**
* Returns an array of documents. The caller is responsible for making sure that there
* is enough memory to store the results. Note that the array only contain partial
* results when this cursor had been previouly accessed.
* results when this cursor had been previously accessed.
* @method CommandCursor.prototype.toArray
* @param {CommandCursor~toArrayResultCallback} [callback] The result callback.
* @throws {MongoError}
......@@ -275,7 +275,7 @@ CommandCursor.prototype.get = CommandCursor.prototype.toArray;
/**
* Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
* not all of the elements will be iterated if this cursor had been previouly accessed.
* not all of the elements will be iterated if this cursor had been previously accessed.
* In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike
* **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements
* at any given time if batch size is specified. Otherwise, the caller is responsible
......
......@@ -693,7 +693,7 @@ Cursor.prototype.skip = function(value) {
/**
* Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
* not all of the elements will be iterated if this cursor had been previouly accessed.
* not all of the elements will be iterated if this cursor had been previously accessed.
* In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike
* **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements
* at any given time if batch size is specified. Otherwise, the caller is responsible
......@@ -811,7 +811,7 @@ Cursor.prototype.setReadPreference = function(readPreference) {
/**
* Returns an array of documents. The caller is responsible for making sure that there
* is enough memory to store the results. Note that the array only contains partial
* results when this cursor had been previouly accessed. In that case,
* results when this cursor had been previously accessed. In that case,
* cursor.rewind() can be used to reset the cursor.
* @method
* @param {Cursor~toArrayResultCallback} [callback] The result callback.
......@@ -845,7 +845,7 @@ Cursor.prototype.toArray = function(callback) {
* @param {object} [options] Optional settings.
* @param {number} [options.skip] The number of documents to skip.
* @param {number} [options.limit] The maximum amounts to count before aborting.
* @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
* @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
* @param {string} [options.hint] An index name hint for the query.
* @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
* @param {Cursor~countResultCallback} [callback] The result callback.
......
......@@ -113,7 +113,7 @@ const legalOptionNames = [
* @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys.
* @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
* @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
* @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported)
* @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported)
* @property {(Server|ReplSet|Mongos)} serverConfig Get the current db topology.
* @property {number} bufferMaxEntries Current bufferMaxEntries value for the database
* @property {string} databaseName The name of the database this instance represents.
......@@ -355,7 +355,7 @@ const collectionKeys = [
* @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
* @param {boolean} [options.strict=false] Returns an error if the collection does not exist
* @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
* @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported)
* @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported)
* @param {Db~collectionResultCallback} [callback] The collection result callback
* @return {Collection} return the new Collection instance if not in strict mode
*/
......@@ -595,7 +595,7 @@ Db.prototype.listCollections = function(filter, options) {
* @param {Code} code JavaScript to execute on server.
* @param {(object|array)} parameters The parameters for the call.
* @param {object} [options] Optional settings.
* @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaulation of the javascript.
* @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaluation of the javascript.
* @param {ClientSession} [options.session] optional session to use for this operation
* @param {Db~resultCallback} [callback] The results callback
* @deprecated Eval is deprecated on MongoDB 3.2 and forward
......@@ -867,7 +867,7 @@ Db.prototype.setProfilingLevel = function(level, options, callback) {
};
/**
* Retrive the current profiling information for MongoDB
* Retrieve the current profiling information for MongoDB
*
* @param {Object} [options] Optional settings
* @param {ClientSession} [options.session] optional session to use for this operation
......
......@@ -234,13 +234,12 @@ function doRead(_this) {
_this.s.bytesToSkip = 0;
}
if (expectedN === _this.s.expectedEnd && _this.s.bytesToTrim != null) {
sliceEnd = _this.s.bytesToTrim;
}
// If the remaining amount of data left is < chunkSize read the right amount of data
if (_this.s.options.end && _this.s.options.end - _this.s.bytesToSkip < buf.length) {
sliceEnd = _this.s.options.end - _this.s.bytesToSkip;
const atEndOfStream = expectedN === _this.s.expectedEnd - 1;
const bytesLeftToRead = _this.s.options.end - _this.s.bytesToSkip;
if (atEndOfStream && _this.s.bytesToTrim != null) {
sliceEnd = _this.s.file.chunkSize - _this.s.bytesToTrim;
} else if (_this.s.options.end && bytesLeftToRead < doc.data.length()) {
sliceEnd = bytesLeftToRead;
}
if (sliceStart != null || sliceEnd != null) {
......
......@@ -65,7 +65,7 @@ const deprecationFn = deprecate(() => {},