Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

require("mongojs").connect is undefined

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

var databaseUrl = "localhost:27017/pixelmargin"; // "username:[email protected]/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)

like image 289
Arun Thampi Avatar asked Apr 18 '26 11:04

Arun Thampi


1 Answers

According to the documentation there is no .connect()

You select the db via the following:

var mongojs = require("mongojs");
var db = mongojs("dbname");
like image 61
secretformula Avatar answered Apr 20 '26 00:04

secretformula



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!