Last active
August 28, 2017 21:17
-
-
Save romelperez/16f669a813a65ab96412d2876da8394f 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
# backup | |
mongodump --db=mydb --archive=./backups/mydb.mongodump --authenticationDatabase=mydb -u username -p | |
# restore | |
mongorestore --drop --archive=./backups/mydb.mongodump --authenticationDatabase=mydb -u username -p | |
# export | |
mongoexport --db mydb --collection users --out ./test/fixtures/users.json --pretty --jsonArray | |
# import | |
mongoimport --db mydb --collection users --file ./test/fixtures/users.json --drop --jsonArray |
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
use admin; | |
db.createUser({ | |
user: 'superadmin', | |
pwd: '12345678', | |
roles: [ 'root' ] | |
}); | |
use appdb; | |
db.createUser({ | |
user: 'programmer', | |
pwd: '12345678', | |
roles: [{ | |
db: 'appdb', | |
role: 'readWrite' | |
}] | |
}); | |
db.auth('programmer', '12345678'); | |
db.createCollection('users'); | |
const usersList = [{ | |
"_id" : ObjectId("5813bc184b57665d404678bc"), | |
"name" : "Pepe Pérez", | |
"email" : "pepeperez@gmail.com", | |
"pwd" : "11111111" | |
}, { | |
"_id" : ObjectId("5813bc184b57665d404678bd"), | |
"name" : "María Rodriguez", | |
"email" : "mariarodriguez@gmail.com", | |
"pwd" : "22222222" | |
}, { | |
"_id" : ObjectId("5813bc184b57665d404678be"), | |
"name" : "Carlos Martínez", | |
"email" : "carlosmartinez@outlook.com", | |
"pwd" : "33333333" | |
}, { | |
"_id" : ObjectId("5813bc184b57665d404678bf"), | |
"name" : "Sandra Molina", | |
"email" : "sandramolina@yahoo.com", | |
"pwd" : "44444444" | |
}]; | |
usersList.forEach(function (user) { | |
db.users.insert(user); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment