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

Raw option set on collection level doesn't propagate to most of the operations

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0
    • Affects Version/s: 3.5.4
    • Component/s: None
    • 0
    • Not Needed

      find seems to be one of few operations that respect raw option set on collection level. aggregate and others do not respect it

      const collection = db.collection('test', { raw: true });
      
      // ok: returns buffer
      await collection.find({}).limit(1).toArray();
      // also ok because it uses find under the hood
      await collection.findOne({});
      
      // not ok: returns deserialized document
      await collection.aggregate([{ $limit: 1 }]).toArray();
      // returns buffer as expected when option is set on operation level
      await collection.aggregate([{ $limit: 1 }], { raw: true }).toArray();
      
      // not ok: returns deserialized data
      await collection.distinct('_id');
      // not ok: returns deserialized document
      await collection.insertOne({ x: 1 });
      // ...etc
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            konanmentor@gmail.com Aliaksei Tuzik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: