-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.5.4
-
Component/s: 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