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

Passing validateBeforeSave:false via params.mongoose does not work. #257

Open
flight9 opened this issue Aug 30, 2018 · 3 comments
Open

Passing validateBeforeSave:false via params.mongoose does not work. #257

flight9 opened this issue Aug 30, 2018 · 3 comments
Labels

Comments

@flight9
Copy link

flight9 commented Aug 30, 2018

Steps to reproduce

There is a Users Schema in my project with a password field which is set to 'required: true'.
Now I have to create a list of users using data from an excel file which does not offer any password value (because the boss hopes no password can be touched by client users).
So I have to skip the mongoose validation when I call feathers service to create a user.
I found in docs here that params.mongoose will help (see https://github.com/feathersjs-ecosystem/feathers-mongoose#paramsmongoose).
I use the code:

let createParams = {
  user: params.user,
  mongoose: { validateBeforeSave: false }
};
for (let k in newDocs) {
  let doc = newDocs[k];
  console.log('newDoc before:', JSON.stringify(doc, null, 2));
  let ok = await service.create(doc, createParams);
}

but it still validates the doc and throw an error Path password is required.

Expected behavior

Passing validateBeforeSave:false via params.mongoose should skip mongoose validating before creating.

Actual behavior

Passing validateBeforeSave:false via params.mongoose does not work.

System configuration

Version
node.js: 8.9.3
mongoose: 5.2.3
MongoDB: 3.6.1
feathers-mongoose: 6.1.2

@stale
Copy link

stale bot commented Nov 22, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.

@stale stale bot added the wontfix label Nov 22, 2018
@flight9
Copy link
Author

flight9 commented Nov 22, 2018

any idea?

@stale stale bot removed the wontfix label Nov 22, 2018
@daffl daffl added the bug label Nov 22, 2018
@tokisakiyuu
Copy link

same here

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

No branches or pull requests

3 participants