Skip to content

Commit 7298c76

Browse files
authored
revert(collection): reverting collection-mapping features
Reverts #1698. With mongodb/js-bson#253 and other approaches to document-class mapping on the table, we'd like to have further discussion before committing to any one API approach. Reopens NODE-1450
1 parent 5a9fdf0 commit 7298c76

File tree

4 files changed

+2
-385
lines changed

4 files changed

+2
-385
lines changed

lib/collection.js

-9
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,6 @@ Collection.prototype.find = function(query, options, callback) {
422422

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

425-
// automatically call map on the cursor if the map option is set
426-
if (typeof this.s.options.map === 'function') {
427-
cursor.map(this.s.options.map);
428-
}
429-
430425
return typeof callback === 'function' ? handleCallback(callback, null, cursor) : cursor;
431426
};
432427

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

759-
if (typeof this.s.options.unmap === 'function') {
760-
doc = this.s.options.unmap(doc);
761-
}
762-
763754
return executeOperation(this.s.topology, replaceOne, [this, filter, doc, options, callback]);
764755
};
765756

lib/db.js

-2
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ const collectionKeys = [
305305
* @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
306306
* @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
307307
* @param {boolean} [options.strict=false] Returns an error if the collection does not exist
308-
* @param {function} [options.map] Function to map documents returned in find, findOne, and findAndModify commands.
309-
* @param {function} [options.unmap] Function to unmap documents passed to insertOne, insertMany, and replaceOne commands.
310308
* @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
311309
* @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)
312310
* @param {Db~collectionResultCallback} [callback] The collection result callback

lib/operations/collection_ops.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,6 @@ function findAndModify(coll, query, sort, doc, options, callback) {
502502
executeCommand(coll.s.db, queryObject, finalOptions, (err, result) => {
503503
if (err) return handleCallback(callback, err, null);
504504

505-
if (result && result.value && typeof coll.s.options.map === 'function') {
506-
result.value = coll.s.options.map(result.value);
507-
}
508-
509505
return handleCallback(callback, null, result);
510506
});
511507
}
@@ -1046,11 +1042,8 @@ function prepareDocs(coll, docs, options) {
10461042
? options.forceServerObjectId
10471043
: coll.s.db.options.forceServerObjectId;
10481044

1049-
const unmap = typeof coll.s.options.unmap === 'function' ? coll.s.options.unmap : false;
1050-
10511045
// no need to modify the docs if server sets the ObjectId
1052-
// and unmap collection option is unset
1053-
if (forceServerObjectId === true && !unmap) {
1046+
if (forceServerObjectId === true) {
10541047
return docs;
10551048
}
10561049

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

1062-
return unmap ? unmap(doc) : doc;
1055+
return doc;
10631056
});
10641057
}
10651058

0 commit comments

Comments
 (0)