Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何创建与node.js和MongoDB数据库的连接? 那么它在哪里不起作用呢?您是否收到任何错误消息?如果您更专业,则更容易提供帮助:在下面给出的行中,当我在terminalubuntu 12.04 LTS 64位上运行代码时,应该会生成错误。为什么,我_Node.js_Mongodb - Fatal编程技术网

如何创建与node.js和MongoDB数据库的连接? 那么它在哪里不起作用呢?您是否收到任何错误消息?如果您更专业,则更容易提供帮助:在下面给出的行中,当我在terminalubuntu 12.04 LTS 64位上运行代码时,应该会生成错误。为什么,我

如何创建与node.js和MongoDB数据库的连接? 那么它在哪里不起作用呢?您是否收到任何错误消息?如果您更专业,则更容易提供帮助:在下面给出的行中,当我在terminalubuntu 12.04 LTS 64位上运行代码时,应该会生成错误。为什么,我,node.js,mongodb,Node.js,Mongodb,如何创建与node.js和MongoDB数据库的连接? 那么它在哪里不起作用呢?您是否收到任何错误消息?如果您更专业,则更容易提供帮助:在下面给出的行中,当我在terminalubuntu 12.04 LTS 64位上运行代码时,应该会生成错误。为什么,我不知道,请告诉我哪里错了/usr/local/nodejs/bin/MyWork/Live_1/connect.js:10 BSON=require'mongodb'.pure.BSON,^TypeError:undefined不是对象上的函数

如何创建与node.js和MongoDB数据库的连接?
那么它在哪里不起作用呢?您是否收到任何错误消息?如果您更专业,则更容易提供帮助:在下面给出的行中,当我在terminalubuntu 12.04 LTS 64位上运行代码时,应该会生成错误。为什么,我不知道,请告诉我哪里错了/usr/local/nodejs/bin/MyWork/Live_1/connect.js:10 BSON=require'mongodb'.pure.BSON,^TypeError:undefined不是对象上的函数/usr/local/nodejs/bin/MyWork/Live_1/connect.js:10:31 at Module.\u编译Module.js:462:26 at Object.Module.\u extensions..js Module.js:480:10 at Module.load Module.js:357:32 at Function.Module.\u加载Module.js:312:12 at Function.runMain Module.js:503:10 at startup node.js:132:16 at node.js:817:3
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient,
Server = require('mongodb').Server,
ReplSetServers = require('mongodb').ReplSetServers,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Grid = require('mongodb').Grid,
Code = require('mongodb').Code,
BSON = require('mongodb').pure().BSON,
assert = require('assert');

// Set up the connection to the local db
var mongoclient = new MongoClient(new Server("localhost", 27017), {native_parser: true});

// Open the connection to the server
mongoclient.open(function(err, mongoclient) {

// Get the first db and do an update document on it
var db = mongoclient.db("braj");
db.collection('logintbl').update({a:1}, {b:1}, {upsert:true}, function(err, result) {
  assert.equal(null, err);
  assert.equal(1, result);

// Get another db and do an update document on it
  var db2 = mongoclient.db("braj");
  db2.collection('logintbl').update({a:1}, {b:1}, {upsert:true}, function(err, result) {
   assert.equal(null, err);
   assert.equal(1, result);

// Close the connection
  mongoclient.close();

    });
  });
});