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