has no method 'connect'

414 views
Skip to first unread message

James C.

unread,
Feb 8, 2011, 6:44:03 PM2/8/11
to Mongoose Node.JS ORM
Hello,
I can't seem to connect to MongoDB. So to create a connection I'm
running:


var mongoose = require('mongoose').Mongoose,
db = mongoose.connect('mongodb://localhost/db');

And I keep getting back:


TypeError: Object function Mongoose() {
this.connections = [];
this.plugins = [];
this.models = {};
this.modelSchemas = {};
this.options = {};
this.createConnection(); // default connection
} has no method 'connect'
at [object Context]:1:25
at Interface.<anonymous> (repl.js:144:22)
at Interface.emit (events.js:42:17)
at Interface._onLine (readline.js:132:10)
at Interface._line (readline.js:387:8)
at Interface._ttyWrite (readline.js:564:14)
at ReadStream.<anonymous> (readline.js:52:12)
at ReadStream.emit (events.js:59:20)
at ReadStream._emitKey (tty_posix.js:280:10)
at ReadStream.onData (tty_posix.js:43:12)

Perhaps my url is incorrect or Mongoose is not configured properly.
I have installed everything via npm and am running osx 10.6. Any
insight would greatly be appreciated.

James

Darrell Banks

unread,
Feb 8, 2011, 6:55:28 PM2/8/11
to mongoo...@googlegroups.com
The latest version doesn't require you to use ('mongoose').Mongoose. Just use require('mongoose')
That should fix your problem!

: )
Reply all
Reply to author
Forward
0 new messages