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

Updating object - Bug or WAD? #13

Open
stefanwalther opened this issue Oct 21, 2019 · 1 comment
Open

Updating object - Bug or WAD? #13

stefanwalther opened this issue Oct 21, 2019 · 1 comment

Comments

@stefanwalther
Copy link

Hi,

I am having the following situation:

  • I have an object with unknown structure (defined by an external system)
  • Let's say it looks as follows
let schema = mongoose.Schema(
    {
      name: 'string',
      size: 'string',
      infos: {
        type: Object,
        required: true,
        default: {}
      }
    }
  );
  schema.plugin(HistoryPlugin);
  let Tank = mongoose.model('tankExtended', schema);

If I now patch the model, the history is always saved, regardless infos has changed or not.

Do you consider this to be a WAD (e.g. I should use a subdocument), or should some deep-checking happening here?

Thx a lot for your answer & this great project!

@Masquerade-Circus
Copy link
Owner

You should check if the option noDiffSave and noDiffSaveMethods are true. If this is the case, change the noDiffSave to false.

  noDiffSave: false, // If true save event even if there are no changes
  noDiffSaveOnMethods: ['delete'], // If a method is in this list, it saves history even if there is no diff.

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