Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. use admin;
  2.  
  3. db.createUser({
  4. user: 'superadmin',
  5. pwd: '12345678',
  6. roles: [ 'root' ]
  7. });
  8.  
  9. use appdb;
  10.  
  11. db.createUser({
  12. user: 'programmer',
  13. pwd: '12345678',
  14. roles: [{
  15. db: 'appdb',
  16. role: 'readWrite'
  17. }]
  18. });
  19.  
  20. db.auth('programmer', '12345678');
  21.  
  22. db.createCollection('users');
  23.  
  24. const usersList = [{
  25. "_id" : ObjectId("5813bc184b57665d404678bc"),
  26. "name" : "Pepe Pérez",
  27. "email" : "pepeperez@gmail.com",
  28. "pwd" : "11111111"
  29. }, {
  30. "_id" : ObjectId("5813bc184b57665d404678bd"),
  31. "name" : "María Rodriguez",
  32. "email" : "mariarodriguez@gmail.com",
  33. "pwd" : "22222222"
  34. }, {
  35. "_id" : ObjectId("5813bc184b57665d404678be"),
  36. "name" : "Carlos Martínez",
  37. "email" : "carlosmartinez@outlook.com",
  38. "pwd" : "33333333"
  39. }, {
  40. "_id" : ObjectId("5813bc184b57665d404678bf"),
  41. "name" : "Sandra Molina",
  42. "email" : "sandramolina@yahoo.com",
  43. "pwd" : "44444444"
  44. }];
  45.  
  46. usersList.forEach(function (user) {
  47. db.users.insert(user);
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement