techpines / express.io

Realtime Micro Framework for Nodejs
express-io.org
1.59k stars 234 forks source link

Mongoose Issue... #52

Open ghost opened 11 years ago

ghost commented 11 years ago

Forgive the nooby question, I feel like I'm missing something dumb here but no matter what I try I can't get this Mongoose query to fire inside my io route here.

Any ideas, anyone?

var mongoose = require('mongoose'),
        User = mongoose.model('User')

var ObjectId = mongoose.Types.ObjectId

module.exports = function(app) {

    app.io.route('user', {
        follow: function(req) {
            User
                .findOne({
                    _id: ObjectId.fromString(req.session.passport.user)
                })
                .exec(function (err, user) {
                    if (err) console.log(err)
                    if (!user) console.log('Failed to load User id ' + req.session.passport.user)
                    // DO STUFF
                })

        },

}
JimtotheB commented 11 years ago

Try instrumenting every step of it.