Skip to content

Instantly share code, notes, and snippets.

@abhitheawesomecoder
Last active November 5, 2017 02:59
Show Gist options
  • Save abhitheawesomecoder/ab79b5dd75c163fb1fce002919007f05 to your computer and use it in GitHub Desktop.
Save abhitheawesomecoder/ab79b5dd75c163fb1fce002919007f05 to your computer and use it in GitHub Desktop.
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