-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Select not working if inside an array for schemas #10029
Comments
I believe this is what you are looking for: otherwise, select is a function call of a query |
Hi @IslandRhythms , he mean if i set select: false in schema still it is showing on find() query
|
@indraraj26 I understand, but in the docs there is no select option when creating a schema. There is a selectPopulatedPaths option which may be what they were referring to which is what I linked. |
Why in this case it is working if there is no such option select: false
Type string
@IslandRhythms i think it was removed in latest version of mongoose or may be it is not updated in docs. I see lot of posts regarding the select: false |
@vkarpov15 is there a select option when defining a schema? Or was it removed recently? Looking at the docs I didn't see it as a listed option. |
@indraraj26 understanding is correct on what Im reporting here. const kittySchema = new mongoose.Schema({
shouldntshow: [{ // <------ it shouldnt show because select is false
type: String,
select: false
}],
doesntshow: { // working correctly
type: [String],
select: false
},
}); It could just be that it is not included in the docs. |
Do you want to request a feature or report a bug?
Possibly a bug where following usage of
select
doesnt seem to do anything. I still see theshouldntshow
field.If intended then please let me know the correct usage.
Note that I have tried doing
type:[String]
.But this approach makes the population methods return nothing. Following script (output at the end of the script) explains this behavior:
Script for populate not working with `[ObjectId]`. Click to expand!
What is the current behavior?
Running the script below which has a schema with two fields set to
select:false
gives the following output.It should not show the
shouldntshow
field.If the current behavior is a bug, please provide the steps to reproduce.
Here is a standalone script for this behavior.
Script for `select:false` not working inside array. Click to expand!
What is the expected behavior?
It should be this. where no fields (specific my example) should show because
select:false
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version..
node: v14.15.4
"mongoose": "^5.12.0"
MongoDB: 4.4.3
The text was updated successfully, but these errors were encountered: