You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.10.5
Node.js version
14.x
MongoDB server version
4.4
Typescript version (if applicable)
No response
Description
The behavior of pre-find hooks is different when we do a .find() query without streaming vs with streaming. The behavior without streaming seems correct. This has been fixed in version 7.2.1 but seems to still exist in version 6.
Steps to Reproduce
const mongoose = require("mongoose");
mongoose.set("debug", true);
const schema = new mongoose.Schema({
name: String,
age: Number,
});
schema.pre("find", function (next) {
console.log("Pre-find hook on Model executed");
this._fields = { age: 1 };
console.log(this._fields);
return next();
});
const Model = mongoose.model("Model", schema);
main().catch((err) => console.log(err));
async function main() {
await mongoose.connect("mongodb://[127.0.0.1:27017/vymo-lms](http://127.0.0.1:27017/test-db)");
await Model.find({}).select("name").exec();
}
Ideally, there should be consistent behavior between both, the cursor behavior seems to be unexpected.
This seems to have been fixed in version 7.2.1(versions below this still seem to have this behavior) in:
fix(cursor): handle calling skipMiddlewareFunction() in pre('find') middleware with cursors #13436#13411
Is it possible to fix this in version 6 as well?
Expected Behavior
No response
The text was updated successfully, but these errors were encountered:
Prerequisites
Mongoose version
6.10.5
Node.js version
14.x
MongoDB server version
4.4
Typescript version (if applicable)
No response
Description
The behavior of pre-find hooks is different when we do a .find() query without streaming vs with streaming. The behavior without streaming seems correct. This has been fixed in version 7.2.1 but seems to still exist in version 6.
Steps to Reproduce
The query produced is:
If we instead do:
The query produced in this case though is:
Ideally, there should be consistent behavior between both, the cursor behavior seems to be unexpected.
This seems to have been fixed in version 7.2.1(versions below this still seem to have this behavior) in:
fix(cursor): handle calling skipMiddlewareFunction() in pre('find') middleware with cursors #13436 #13411
Is it possible to fix this in version 6 as well?
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: