Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

TypeError: Cannot call method 'find' of undefined #306

Closed
mihaipaun opened this Issue · 8 comments

6 participants

Mihai Păun Joshua Anderson Matthew Eernisse Daniel Erickson David Archer Larz Conwell
Mihai Păun

I'm having a issue when I try to use mongo for persistence. This is the output that I get in the console when I try to list all the items of a model (e.g. http://localhost:4000/todos)

/path_to_app/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/connection/server.js:524
        throw err;
              ^
TypeError: Cannot call method 'find' of undefined
...
     ERROR Worker 10591 died.

I've set up the config object in config/development.js like so:

var config = {
  detailedErrors: true
, debug: true
, hostname: 'localhost'
, port: 4000
, model: {
    defaultAdapter: 'mongo'
  }
, db: {
  mongo: {
    dbname: 'test'
  }
}
, sessions: {
    store: 'memory'
  , key: 'sid'
  , expiry: 14 * 24 * 60 * 60
  }
};

module.exports = config;

Also, I have mongodb-wrapper installed locally.

Does anyone know what could be the issue here?

Joshua Anderson

Verify the mongo instance is fine by utilizing the shell - terminal - type mongo. http://docs.mongodb.org/manual/tutorial/getting-started-with-the-mongo-shell/#start-the-mongo-shell

You may find this question annoying but it is a first step.

Matthew Eernisse
Owner
mde commented

Looks like mongodb-wrapper has changed enough that we need to specify a version, or update Model to use the newest. A guy in IRC said it needs to be 0.4.x.

This raises the question of how we can specify versions for libraries that are assumed to be locally installed inside the app. Here's the issue I've opened for this:

geddy/model#24

Daniel Erickson
Owner
Mihai Păun

It worked with "mongodb-wrapper": "0.4.x". Thanks!

David Archer

Hi, I'm also having this problem. Where do you specify that tag, how do you install that version of the mongodb wrapper (OSX)?

Larz Conwell

Kumoriuk you'll need to edit your package.json and add the mongodb line to tour existing dependencies.

{
   "dependencies": {
      "mongodb-wrapper": "0.4.x"
    }
}

Then you should do npm install

David Archer

That did the trick, thank you!

Larz Conwell

You're welcome, glad I could help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.