Oktatás * Programozás 2 * Szkriptnyelvek * levelezősök Félévek Linkek * kalendárium |
NoSql /
CommandsMongoDB Commands Dump a database: mongodump -d <db_name> Where Restore a database: mongorestore [--drop] Supposing you are in the directory where the folder If you specify Restore a specific collection: mongorestore [--drop] -d <db_name> -c <coll_name> dump/file.bson # concrete example: # mongorestore --drop -d movies -c movieDetails dump/movieDetails.bson If you specify Import from a JSON file #1: Suppose you have a JSON file, where each line contains a document: { name: "Widget 1", desc: "This is Widget 1" } { name: "Widget 2", desc: "This is Widget 2" } You can import it the following way: mongoimport [--drop] -d <db-name> -c <coll-name> --type json location/of/input.json Import from a JSON file #2: Suppose you have a JSON file, where you have an array of documents: [ { "color": "red", "value": "#f00" }, { "color": "green", "value": "#0f0" } ] You can import it the following way: mongoimport [--drop] -d <db-name> -c <coll-name> --type json --jsonArray location/of/input.json Make sure you are using the |
Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |