Last active
November 5, 2017 02:59
-
-
Save abhitheawesomecoder/ab79b5dd75c163fb1fce002919007f05 to your computer and use it in GitHub Desktop.
This file contains 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
import Sequelize from 'sequelize'; | |
import casual from 'casual'; | |
import _ from 'lodash'; | |
import bcrypt from 'bcrypt'; | |
const password = "test123" | |
const db = new Sequelize('blog', null, null, { | |
dialect: 'sqlite', | |
storage: './blog.sqlite', | |
}); | |
const UserModel = db.define('user', { | |
firstName: { type: Sequelize.STRING }, | |
lastName: { type: Sequelize.STRING }, | |
email: { type: Sequelize.STRING }, | |
password: { type: Sequelize.STRING }, | |
}); | |
casual.seed(123); | |
db.sync({ force: true }).then(() => { | |
_.times(10, () => { | |
return bcrypt.hash(password, 10).then(hash => UserModel.create({ | |
firstName: casual.first_name, | |
lastName: casual.last_name, | |
email: casual.email, | |
password: hash | |
}) | |
) | |
}); | |
}); | |
const User = db.models.user; | |
export { User }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment