Guest User

Untitled

a guest
Nov 7th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import Sequelize from 'sequelize';
  2. import casual from 'casual';
  3. import _ from 'lodash';
  4. import bcrypt from 'bcrypt';
  5. const password = "test123"
  6.  
  7. const db = new Sequelize('blog', null, null, {
  8. dialect: 'sqlite',
  9. storage: './blog.sqlite',
  10. });
  11.  
  12. const UserModel = db.define('user', {
  13. firstName: { type: Sequelize.STRING },
  14. lastName: { type: Sequelize.STRING },
  15. email: { type: Sequelize.STRING },
  16. password: { type: Sequelize.STRING },
  17. });
  18.  
  19. casual.seed(123);
  20. db.sync({ force: true }).then(() => {
  21. _.times(10, () => {
  22. return bcrypt.hash(password, 10).then(hash => UserModel.create({
  23. firstName: casual.first_name,
  24. lastName: casual.last_name,
  25. email: casual.email,
  26. password: hash
  27. })
  28. )
  29. });
  30. });
  31.  
  32. const User = db.models.user;
  33.  
  34.  
  35. export { User };
Add Comment
Please, Sign In to add comment