Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert(collection): reverting collection-mapping features #1750

Merged
merged 1 commit into from
Jun 25, 2018
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
9 changes: 0 additions & 9 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,6 @@ Collection.prototype.find = function(query, options, callback) {

const cursor = this.s.topology.cursor(this.s.namespace, findCommand, newOptions);

// automatically call map on the cursor if the map option is set
if (typeof this.s.options.map === 'function') {
cursor.map(this.s.options.map);
}

return typeof callback === 'function' ? handleCallback(callback, null, cursor) : cursor;
};

Expand Down Expand Up @@ -756,10 +751,6 @@ Collection.prototype.replaceOne = function(filter, doc, options, callback) {
options.ignoreUndefined = this.s.options.ignoreUndefined;
}

if (typeof this.s.options.unmap === 'function') {
doc = this.s.options.unmap(doc);
}

return executeOperation(this.s.topology, replaceOne, [this, filter, doc, options, callback]);
};

Expand Down
2 changes: 0 additions & 2 deletions lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ const collectionKeys = [
* @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
* @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 {function} [options.map] Function to map documents returned in find, findOne, and findAndModify commands.
* @param {function} [options.unmap] Function to unmap documents passed to insertOne, insertMany, and replaceOne commands.
* @param {object} [options.readConcern=null] 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 {Db~collectionResultCallback} [callback] The collection result callback
Expand Down
11 changes: 2 additions & 9 deletions lib/operations/collection_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,6 @@ function findAndModify(coll, query, sort, doc, options, callback) {
executeCommand(coll.s.db, queryObject, finalOptions, (err, result) => {
if (err) return handleCallback(callback, err, null);

if (result && result.value && typeof coll.s.options.map === 'function') {
result.value = coll.s.options.map(result.value);
}

return handleCallback(callback, null, result);
});
}
Expand Down Expand Up @@ -1046,11 +1042,8 @@ function prepareDocs(coll, docs, options) {
? options.forceServerObjectId
: coll.s.db.options.forceServerObjectId;

const unmap = typeof coll.s.options.unmap === 'function' ? coll.s.options.unmap : false;

// no need to modify the docs if server sets the ObjectId
// and unmap collection option is unset
if (forceServerObjectId === true && !unmap) {
if (forceServerObjectId === true) {
return docs;
}

Expand All @@ -1059,7 +1052,7 @@ function prepareDocs(coll, docs, options) {
doc._id = coll.s.pkFactory.createPk();
}

return unmap ? unmap(doc) : doc;
return doc;
});
}

Expand Down
Loading