mysql - findOne doesn't get any record -
login: function (req, res) { var username = req.param('username'); var password = req.param('password'); user.findone({username: username}, function (err, user) { if (err || !user) { return res.status('401').send("user username \"" + username + "\" not found. registered?"); } ... gives me undefined user object , end in error statement. username variable has correct value. method, create records, works (so connection db alright), , when db, record there, correct data.
i tried user.find().where({username: username}).exec(function (err, user) { no success...
any suggestions can (debugging or smth) or might cause of problem?
jonathan's comment inspect err pointed me in right direction. user model follows:
attributes: { // relations passports: { model: 'passport' }, //... other attributes and have relation belongsto declared in passport model. err giving details: error: er_bad_field_error: unknown column 'users.passports' in 'field list', , of course in user table in database did not have passports column.
conclusion: had unnecessary entity relation declaration in user model. working fine mongodb, apparently mysql things quite different.
Comments
Post a Comment