-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projection with '+' using findByIdAndUpdate does not return the property #13413
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
Maybe related to #13340 |
IslandRhythms
added
the
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
label
May 22, 2023
Tested on 7.2 const mongoose = require('mongoose');
const testSchema = new mongoose.Schema({
name: String,
nickName: {
type: String,
select: false
}
});
const Test = mongoose.model('Test', testSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017');
await mongoose.connection.dropDatabase();
const entry = await Test.create({
name: 'Test Testerson',
nickName: 'Quiz'
});
const res = await Test.findByIdAndUpdate(entry._id, { $set: { name: 'Test' } }, { projection: '+nickName', returnDocument: 'after'});
console.log(res);
}
run(); |
vkarpov15
added a commit
that referenced
this issue
May 24, 2023
vkarpov15
added a commit
that referenced
this issue
May 24, 2023
fix(query): handle plus path in projection with findOneAndUpdate()
vkarpov15
added a commit
that referenced
this issue
May 25, 2023
AbdelrahmanHafez
added a commit
that referenced
this issue
May 25, 2023
test(findOneAndUpdate): add extra assertions from code review for #13437
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
7.1.1
Node.js version
18.7.0
MongoDB server version
5.5.0
Typescript version (if applicable)
5.0.4
Description
When using
select: false
for a propertyx
in a schema,x
is not returned when usingfindByIdAndUpdate
andprojection: '+x'
.Only started occurring in 7.1.1, I don't see this issue <= 7.1.0.
Steps to Reproduce
In a schema:
Then try to do:
response
does not containx
.Expected Behavior
The property is returned.
The text was updated successfully, but these errors were encountered: