Skip to content

Conversation

@DenisNazarenko
Copy link

PR for #18

@DenisNazarenko DenisNazarenko self-assigned this Nov 12, 2019
userSchema.set('timestamps', true);
const User = mongoose.model('User', userSchema);

export default User;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also often it is good to use Joi (https://github.com/hapijs/joi) for api request validation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also often it is good to use Joi (https://github.com/hapijs/joi) for api request validation

==> 080004d#r349572310

});
userSchema.set('timestamps', true);

userSchema.methods.JoiValidate = (obj) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klishevich Майкл, как тебе такой вариан? Добавил метод, который можно вызывать при crud и обрабатывать.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DenisNazarenko выглядит норм, теперь только осталось его вызывать при каждой операции. Он вроде ошибки должен нормально формировать, которые на клиента можно возвращать

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

Successfully merging this pull request may close these issues.

3 participants