mongojs icon indicating copy to clipboard operation
mongojs copied to clipboard

Connection Problem

Open ghaddon opened this issue 11 years ago • 2 comments

Having problem connecting to MongoDB 3.04 with Mongojs 1.2.1. I'm not starting MongoDB in auth mode.

Source code found in server.js:

var http = require('http'); var express = require('express'); var app = express(); var mongojs = require('mongojs');

var db = mongojs('homemanager', ['contactlist']);

db.on('error', function (err) { console.log('database error', err) })

app.use(express.static(__dirname + '/public'));

app.get('/contactlist', function (req, res) { console.log("I recieved a get request");

db.contactlist.find(function (err, docs) {
    create.log(docs);
    res.json(docs);
});

});

app.listen(3000); console.log('Server running on Port 3000');

Error Message back to Nodejs console:

C:\Users\Gary\Documents\Visual Studio 2015\Projects\NodeTestApp\NodeTestApp\serv er.js:8 db.on('error', function (err) { ^ TypeError: undefined is not a function at Object. (C:\Users\Gary\Documents\Visual Studio 2015\Projects\N odeTestApp\NodeTestApp\server.js:8:4) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3

Any help greatly appreciated. Gary

ghaddon avatar Aug 06 '15 18:08 ghaddon

I'm experiencing the same problem with both db.on('ready', function()) and db.on('error', function()).

joxford531 avatar Aug 09 '15 18:08 joxford531

Fixed in version 1.3.0

saintedlama avatar Aug 14 '15 11:08 saintedlama