-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Milestone
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.9.1
Node.js version
16.x
MongoDB server version
Any
Typescript version (if applicable)
No response
Description
The following script shows that Mongoose sends projection: {}
to the MongoDB driver, which is unnecessary. Would be ideal if Mongoose didn't set a projection
option if the projection is empty.
'use strict';
const mongoose = require('mongoose');
mongoose.set('debug', true);
run().catch(err => console.log(err));
async function run() {
await mongoose.connect('mongodb://localhost:27017/test');
const schema = new mongoose.Schema({ name: String });
const Test = mongoose.model('Test', schema);
// Prints "Mongoose: tests.findOne({}, { projection: {} })"
await Test.findOne(); // Sends `projection: {}` to MongoDB
}
Steps to Reproduce
See above
Expected Behavior
No response
Metadata
Metadata
Assignees
Labels
No labels