-
Type:
New Feature
-
Resolution: Won't Do
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
Summary: It'd be nice to add way to create a collection instance and automatically call map/transform any time a document gets pulled from the database. This would make it easy for mapping libraries (https://github.com/j/type-mongo-mapper) to be used without having to create a wrapper around the collection.
Note: I know there's cursor.map and "extending cursors". But just a simple:
const mappedCollection = db.collection('users', { map: createUserDocumentMapper() });
mappedCollection.find*() // every document will be put through the map function
Please see the link below with examples:
https://github.com/mongodb-js/mongodb-core/issues/301#issuecomment-384773766
- links to