mongoose-diff-history icon indicating copy to clipboard operation
mongoose-diff-history copied to clipboard

Omit path not working with array of subdocuments

Open denes16 opened this issue 2 years ago • 1 comments

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 avatar Apr 01 '22 14:04 denes16

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

denes16 avatar Apr 01 '22 14:04 denes16