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

Omit path not working with array of subdocuments #76

Open
denes16 opened this issue Apr 1, 2022 · 1 comment
Open

Omit path not working with array of subdocuments #76

denes16 opened this issue Apr 1, 2022 · 1 comment

Comments

@denes16
Copy link

denes16 commented Apr 1, 2022

Hi.
I have a document, its schema looks like this.

new mongoose.Schema({
  items: [
{
  name: String,
 currentValue: Number
}],
  totalCurrentValue: Number,
}, {timestamps: true});

I've added items.currentValue and totalCurrentValue to the omit options, and its omitting totalCurrentValue correctly, but its not ignoring changes on 'items.currentValue'.
Note: By default, mongoose adds and _id field on every array item, i've checked it, and the _id its not modified, because i'm only modifying the currentValue field, sometimes adding it or removing or just updating, and not modifying the entire array, so this its not the reason of the issue.

The diff object looks like this, when i add the items.currentValue' field.

{
items: {
0: {
  currentValue: 2,
},
_t: "a"
}

Thanks in advice

@denes16
Copy link
Author

denes16 commented Apr 1, 2022

I can create a pr, just let me know which files i need to change or its not a real issue

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

1 participant