Skip to content
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

Model.hydrate doesn't select projections #11375

Closed
RayofLightz opened this issue Feb 10, 2022 · 0 comments
Closed

Model.hydrate doesn't select projections #11375

RayofLightz opened this issue Feb 10, 2022 · 0 comments
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@RayofLightz
Copy link

When passing a projections object to Model.hydrate it does not actually select the fields from the projection like the documentation states.
According to the hydration docs
projection fields "should be selected for this document".

const mongoose = require('mongoose');
const PieSchema = new mongoose.Schema({ filling : String, hoursToMake : Number, tasteRating : Number });
const Pie = mongoose.model('Pie', PieSchema);
console.log(Pie.hydrate({ filling : 'cherry', hoursToMake : 2 }, { filling : 1 }));
// Outputs { filling : 'cherry', hoursToMake : 2 }

It should be returning { filling : 'cherry' }

I am on 14.18.3 of node, 5.13.2 of mongoose, and 4.4.6 of mongo

@IslandRhythms IslandRhythms added the confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. label Feb 10, 2022
@vkarpov15 vkarpov15 added this to the 6.2.2 milestone Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

No branches or pull requests

3 participants