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

XMLWordPrintableJSON

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

      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
              Reporter:
              Aliaksei Tuzik
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: