Skip to content

Commit ab3f2cc

Browse files
committed
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 2dba264 commit ab3f2cc

File tree

3 files changed

+2
-383
lines changed

3 files changed

+2
-383
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/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)