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

Bug: Schema minimize option are overriden for references #9405

Closed
maloguertin opened this issue Sep 9, 2020 · 0 comments
Closed

Bug: Schema minimize option are overriden for references #9405

maloguertin opened this issue Sep 9, 2020 · 0 comments
Milestone

Comments

@maloguertin
Copy link

bug

What is the current behavior?

The minimize option of a referenced schema is overriden by it's parent.

If the current behavior is a bug, please provide the steps to reproduce.

Take this schema:

const userSchema = mongoose.Schema({
  adress: { type: mongoose.Schema.ObjectId, ref: 'adresses' }
})

const adressSchema = mongoose.Schema({
  zip: { type: String },
  country: { type: Object, default: {}}
}, {minimize: false})

if I query userSchema and populate the adress field

console.log(user) outputs { adress: {zip: "1234"} }

console.log(user.adress) outputs {zip: "1234", country: {} }

What is the expected behavior?

referenced schemas options should be taken into account instead of overriden.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

mongoose: 5.9.4
mongodb: 4.2.8
node: 10.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants