zoukankan      html  css  js  c++  java
  • 01demo-mongodb

    var mongodb=require('mongodb');
    var server=new mongodb.Server('127.0.0.1',27017,{});
    var client=new mongodb.Db('mydatabase1',server,{w:1});//数据库名?存储位置?
    client.open(function(err){
    	if(err){throw err;}
    	client.collection('test_insert',function(err,collection){//表名?
    		if(err) throw err;
    		console.log(888888);
    		collection.insert(
    			{
    				"title":"i like you",
    				"body":"it's true"
    			},
    			{safe:true},
    			function(err,documents){//安全模式表明数据库操作在回调之前完成
    				if(err) throw err;
    				console.log('document id is'+ JSON.stringify(documents));
    		});
    		collection.find({"title":"i like you"}).toArray(
    			function(err,results){
    				if(err) throw err;
    				console.log(results);
    			}
    		);
    	});
    });
    

      

  • 相关阅读:
    Interesting Finds: 2009 01.15 ~ 01.17
    Interesting Finds: 2008.12.07
    Interesting Finds: 2008.12.31
    10月16号
    10月14号
    10月15号
    10月13号
    10月20号
    10月19号
    10月12号
  • 原文地址:https://www.cnblogs.com/hhweb/p/6364593.html
Copyright © 2011-2022 走看看