mongooserailway.js

Model.find() not finding in Mongoose with RailwayJS


I'm having real trouble using find in my test railwayjs app. In my model:

data is => "email":"test","password":"[FILTERED]"

Model

User.login = function(data){
    var user = new User;
    user.email = data.email;
    console.log('user email is => ' + user.email);
    user.password = data.password;
    User.find({email: user.email}, function(err, user){
        console.log(user);
    });
}

Output

user email is => test
null

Where test is in my database (mongoose running as mongod).

I really cant figure out why its coming up null..

I use user.save() elsewhere and it saves to the database fine.

I am a total rookie, so it could be something obvious, any help / pointers is massively appreciated.

edit

To add to this:

User.all(function (err, users) {
        console.log(users);
        render({
            users: users
        })
    });

works perfectly...


Solution

  • I've reported this as a bug on the Google Group.

    Edit: It turns out that you must now do this:

    User.all({ where: { email: user.email } }, function(err, user){
    

    The documentation is available at JugglingDB Github. It should be updated in the RailwayJS website too.