Skip to content

Instantly share code, notes, and snippets.

@talyssonoc
Created April 4, 2017 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save talyssonoc/08ef480a2451548d904f472e63b3bd7f to your computer and use it in GitHub Desktop.
Save talyssonoc/08ef480a2451548d904f472e63b3bd7f to your computer and use it in GitHub Desktop.
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