Guest User

Untitled

a guest
Feb 22nd, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. 'use strict'
  2.  
  3. /*
  4. |--------------------------------------------------------------------------
  5. | UserSeeder
  6. |--------------------------------------------------------------------------
  7. |
  8. | Make use of the Factory instance to seed database with dummy data or
  9. | make use of Lucid models directly.
  10. |
  11. */
  12.  
  13. const Factory = use('Factory')
  14. const Hash = use('Hash')
  15. const User = use('App/Models/User')
  16.  
  17. class UserSeeder {
  18. async run () {
  19. // menggunakan user factory
  20. const usersArray = await Factory
  21. .model('App/Models/User')
  22. .createMany(5)
  23.  
  24. // menggunakan User model
  25. const user = new User()
  26. user.username = 'ahmadarif'
  27. user.email = 'ahmad.arif019@gmail.com'
  28. user.password = '123'
  29. await user.save()
  30. }
  31. }
  32.  
  33. module.exports = UserSeeder
Add Comment
Please, Sign In to add comment