3

I just started to learn mongodb. I tried the following code in my app.js

var databaseUrl = "localhost:27017/pixelmargin"; // "username:password@example.com/mydb"
var collections = ["pages"]
var mongojs = require("mongojs");
var db = mongojs.connect(databaseUrl)

But I get the following error:

Uncaught TypeError: undefined is not a function ' error occurs on line 'var db = mongojs.connect(databaseUrl)

secretformula
  • 6,414
  • 3
  • 33
  • 56
Arun Thampi
  • 41
  • 1
  • 6

2 Answers2

9

According to the documentation there is no .connect()

You select the db via the following:

var mongojs = require("mongojs");
var db = mongojs("dbname");
secretformula
  • 6,414
  • 3
  • 33
  • 56
0

That works for me :

var db = require('mongojs').connect('localhost:27017/dbName');
Jérémy Pouyet
  • 1,989
  • 6
  • 28
  • 55