Samuel Martín
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
show dbs
use hello
db.world.find()
db.world.insert({test: "welcome to mongoDB!"})
db.world.find()
exit
var MongoClient = require('mongodb').MongoClient;
// Open the connection to mongoDB to database named 'hello'
MongoClient.connect('mongodb://127.0.0.1:27017/hello', function(err, db) {
if(err) throw err;
// Find one document in our collection 'world'
db.collection('world').findOne({}, function(err, doc) {
if(err) throw err;
// Print the result if found or null if not found.
console.dir(doc);
// It's important to close the DB after you have finished
db.close();
});
});
{ _id: 5711f731318961da658a8426, test: 'welcome to mongoDB!' }