Created
October 2, 2017 13:33
-
-
Save frknbasaran/bad6f6eec014a1ccde39b0c47deb8297 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
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