A sample of my schema,
const XXXSchema = new mongoose.Schema({
name: String
}
I am using mongoose for awhile, and just recently I started experience the issues. The following query works as expected,
await MyModel.find({_id: ObjectId(SOME NUMBER)}).exec()
However, it always returns all documents if I query using any other fields, regardless value. For example,
await MyModel.find({anotherField: "some value"}).exec()
I tried to use callback, but the result is the same. Could someone help? The mongodb version I use is 5.0.2. Thanks.
Update: I reviewed mongoose query debug, and found, mongoose ignored my filter, and only send an empty {} as the filter.