banner ad

Node.JS + MongoDB

| March 23, 2013 | 0 Comments
0 Flares 0 Flares ×
var MongoDB = require('MongoDB');
var server = new mongoDB.Server('localhost',27017,{auto_reconnect:true});
var db = new mongoDB.Db('dbyeah',server,{safe:true});

db.open(function(err,db){
	if(!err)
	{
		console.log('Connected!');
		db.collection('books',{safe:true},function(err,collection){
			var post ={name:'Computer 133',page:135};
			collection.insert(post,{safe:true},function(err,result){
				console.log(result);
			});
		});
	}
	else
	{
		console.log('Fail to Connecte!');
	}
});
Download PDF
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Reddit 0 StumbleUpon 0 0 Flares ×

Tags: ,

Category: Uncategorized

About the Author ()

My name is John Link.I am 26 years old. My major is Computer science and technology. I am a junior programmer with Python.

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Reddit 0 StumbleUpon 0 0 Flares ×