Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1450

Ability to define transformer / mapper on the collection level.

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON, Native
    • Labels:
    • Not Needed
    • Not Needed

      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            jstout24 Jordan Stout
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: