javascript - MongoDB -- client.open() returns "undefined in not a function" -
here's have:
var express = require('express'); var mongoclient = require('mongodb').mongoclient; var server = require('mongodb').server; var app = express(); var client = new mongoclient(new server('localhost', 27017, {}), {}); client.open(function(err, client){ //callback });
and when run it, points line open method on , says "undefined not function". doing wrong?
from mongo docs :
var mongoclient = require('mongodb').mongoclient // connection url var url = 'mongodb://localhost:27017/myproject'; // use connect method connect server mongoclient.connect(url, function(err, db) { console.log("connected correctly server"); db.close(); });
Comments
Post a Comment