Прошу сильно не пинать.
Изучаю nodejs, express и mongodb
Попутно пытаюсь сделать все что показано в этом скринкасте
Но в этом месте:
app.get('/user/:id', function(req, res, next){
User.findById(req.params.id, function(err, user){
if(err) return next(err);
res.json(user);
});
});
Express
500 CastError: Cast to ObjectId failed for value "586f2862632df73c31f25df3" at path "_id" for model "User"
at MongooseError.CastError (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/error/cast.js:26:11)
at ObjectId.cast (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/schema/objectid.js:147:13)
at ObjectId.castForQuery (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/schema/objectid.js:187:15)
at cast (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/cast.js:229:32)
at Query.cast (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/query.js:2752:12)
at Query.findOne (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/query.js:1353:10)
at Function.findOne (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/model.js:1343:13)
at Function.findById (/home/farex/dev/nodejs_dev/lessons_30/node_modules/mongoose/lib/model.js:1271:15)
at /home/farex/dev/nodejs_dev/lessons_30/app.js:42:8
at callbacks (/home/farex/dev/nodejs_dev/lessons_30/node_modules/express/lib/router/index.js:164:37)
at param (/home/farex/dev/nodejs_dev/lessons_30/node_modules/express/lib/router/index.js:138:11)
at param (/home/farex/dev/nodejs_dev/lessons_30/node_modules/express/lib/router/index.js:135:11)
at pass (/home/farex/dev/nodejs_dev/lessons_30/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/home/farex/dev/nodejs_dev/lessons_30/node_modules/express/lib/router/index.js:173:5)
at Object.router (/home/farex/dev/nodejs_dev/lessons_30/node_modules/express/lib/router/index.js:33:10)
at next (/home/farex/dev/nodejs_dev/lessons_30/node_modules/connect/lib/proto.js:174:15)
Похоже в новой версии mobgoose, что-то поменялось...