Skip to content

Instantly share code, notes, and snippets.

@frknbasaran
Created October 2, 2017 13:33
Show Gist options
  • Save frknbasaran/bad6f6eec014a1ccde39b0c47deb8297 to your computer and use it in GitHub Desktop.
Save frknbasaran/bad6f6eec014a1ccde39b0c47deb8297 to your computer and use it in GitHub Desktop.
var MongoClient = require('mongodb').MongoClient;
// Connection URL
var url = 'mongodb://localhost:27017/myproject';
// Use connect method to connect to the Server
MongoClient.connect(url, function(err, db) {
console.log("Connected correctly to server");
db.createCollection("gevsek");
db.collection("gevsek").insert({"key1":"val1"}, function(err) {
console.log("data inserted");
})
db.collection("gevsek").insert({"key2":"val2"}, function(err) {
console.log("data inserted");
})
db.collection("gevsek").insert({"key3":"val3"}, function(err) {
console.log("data inserted");
})
db.collection("gevsek").find({}).toArray(function(err, gevseks) {
console.log(gevseks);
})
db.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment