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

[question][Documents] RunValidators is set by default? #255

Closed
ghost opened this issue Aug 12, 2018 · 4 comments
Closed

[question][Documents] RunValidators is set by default? #255

ghost opened this issue Aug 12, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 12, 2018

Hello, this is not an issue, just a question about README. Seem that I don't understand it correctly. Could some guys can explain it, please?
In README, there's an paragraph:

params.mongoose

When making a service method call, params can contain a mongoose property which allows you to modify the options used to run the Mongoose query. Normally, this will be set in a before hook:

app.service('messages').hooks({
  before: {
    patch(context) {
      // Set some additional Mongoose options
      // The adapter tries to use sane defaults
      // but they can always be changed here
      context.params.mongoose = {
        runValidators: true,
        setDefaultsOnInsert: true
      }
    }
  }
});

And here is my concern. With this docs, does it mean runValidators is set to true by default?

@jamesjnadeau
Copy link
Contributor

runValidators is set to true by default. It was set here:
https://github.com/feathersjs-ecosystem/feathers-mongoose/pull/87/files#diff-480db08609ef6a51bf20f049cc9bda48R143

and you can view the defaults used in the update operation here:

runValidators: true,

and here it is in patch:

runValidators: true,

Hope this helps!

@ghost
Copy link
Author

ghost commented Aug 12, 2018

@jamesjnadeau Thank you very much. In source code, it 's set by default, I just concern about documents.

When I read the documents, I think it's not set by default. This option is disable from [mongoose](runValidators is off by default from mongoose, so I'm very surprise while seeing this option in query.

Do you think documents should mention runValidators: true is default for update/patch? It helps someone has bad English like me to understand clearly

@jamesjnadeau
Copy link
Contributor

Maybe? From my understanding the current functionality works like other feathers adapter. I personally think having runValidators set to true is a good choice.

Feel free to submit a pull request with the updated docs.

@ghost
Copy link
Author

ghost commented Aug 13, 2018

@jamesjnadeau I submit this PR.
Thanks for helping!

@ghost ghost closed this as completed Aug 13, 2018
This issue was closed.
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