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

Cursor ReadStream applies map function twice

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.6
    • Affects Version/s: 3.5.4
    • Component/s: None
    • Labels:

      It seems like when I use the cursor as a read stream and I use `map` on the cursor, the map function is applied twice.

      Example:

      client.collection('xxx')
        .find()
        .project({ _id: 1 })
        .map(doc => {}}
          return { doc: doc };
        })
        .on('data', x => console.log('data', x));
      

      Output:

      data { doc: { doc: { _id: '5bb55dd0d6eb334f45811b8e' } } }
      data { doc: { doc: { _id: '5c54e86c7e37c22ce904cd71' } } }
      data { doc: { doc: { _id: '5c5dcaec66b2983808d4b1bb' } } }
      data { doc: { doc: { _id: '5c953939a1650802df5b28fa' } } }
      data { doc: { doc: { _id: '5c968877c666b318f01a84c0' } } }
      data { doc: { doc: { _id: '5c953300654c60739c20f783' } } }
      

       
      Expected:

      data { doc: { _id: '5bb55dd0d6eb334f45811b8e' } }
      data { doc: { _id: '5c54e86c7e37c22ce904cd71' } }
      data { doc: { _id: '5c5dcaec66b2983808d4b1bb' } }
      data { doc: { _id: '5c953939a1650802df5b28fa' } }
      data { doc: { _id: '5c968877c666b318f01a84c0' } }
      data { doc: { _id: '5c953300654c60739c20f783' } }
      

       

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            dobesv@gmail.com Dobes Vandermeer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: