Created
April 4, 2017 02:27
-
-
Save talyssonoc/08ef480a2451548d904f472e63b3bd7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SequelizeUsersRepository { | |
add(user) { | |
const { valid, errors } = user.validate(); | |
if(!valid) { | |
const error = new Error('ValidationError'); | |
error.details = errors; | |
return Promise.reject(error); | |
} | |
return UserModel | |
.create(user.attributes) | |
.then((dbUser) => dbUser.dataValues); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment