0

While trying out the node.js framework geddy (on windows) and i've run into a bit of a problem.

I'm trying to query mongodb, in my controller, using the .first() method from my Users Model like so:

geddy.model.User.first({name: 'jdoe'}, function (err, data) {
  if (err) {
    throw err;
  } else {
    console.log(data);
  }

});

Strangely enough i'm not getting any output, error, nothing. The user jdoe exists in the collection so it should output something, right ? Am i doing something wrong ?

My model is defined as:

var User = function () {

    this.defineProperties({
      username: {type: 'string', required: true},
      password: {type: 'string', required: true},
    });

    this.autoIncrementId = true;

};

User = geddy.model.register('User', User);

The default adapter is set to mongo in development.js, when i ran geddy for the first time it created my database and it has inserted the Users collection correctly.

Any idea on whats going wrong here ?

UPDATE:

added development.js as requested

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

module.exports = config;

also my collections on mongo ( created by geddy )

> show collections
User
system.indexes
users

note that somehow geddy is creating two collections instead of one

mfreitas
  • 2,395
  • 3
  • 29
  • 42
  • Can I get a look at your config file? I won't be able to tell what's going on here without it :) – Techwraith Oct 22 '12 at 20:11
  • Also, can you show me the list of collections in your DB? – Techwraith Oct 22 '12 at 20:12
  • Edited my post with the config and mongo collections. Yesterday the .all()/.first() commands would not query mongo sucessfully, today they do. Wierd! Would it have something to do with the "duplicate" collections being created ? – mfreitas Oct 22 '12 at 21:38

1 Answers1

1

It looks like you're being hit by this bug: https://github.com/mde/geddy/issues/240

As it is, Geddy accidentally creates two collections per model. It always uses the lowercased pluralized collection to do read/writes though. Are you sure that your data was in that collection and not in the other?

At any rate, from the comments, it sounds like you've got this one covered already.

Techwraith
  • 1,298
  • 1
  • 10
  • 12
  • Yes seems to be the same bug, should've checked github before, thanks! Anyway, yes my data allways ends up in the lowercased pluralized collection, the other one remains empty for every model i create. Hope they fix this soon, glad to know its been issued. Thanks for the help – mfreitas Oct 22 '12 at 21:48