无法使用findById传递查询结果

我正在使用节点和mongoose的博客上工作。 在索引页面我能够显示所有的post,但点击标题看到完整的后null值显示。 href链接已被正确插入,并redirect到所需的链接“ http:// localhost:3000 / posts / show / 596e795be0a91a1cdcc572eb ”。 我试着通过ID传递查询。 posts.js – >路由

 var posts = require('../models/posts'); router.get('/show/:id', function(req, res, next) { console.log(req.params.id); posts.findById(req.params.id, function(err, post){ console.log(post); res.render('show',{ "post": post }); }); }); 

posts.js->模型

 var mongoose = require('mongoose'); var Schema = mongoose.Schema; var lists = new Schema({ title:{ type: String, required: true }, author:{ type: String }, _id:{ type: String, }, category:{ type: String }, body:{ type: String, required: true }, date:{ type: Date, default: Date.now } }); var posts = module.exports = mongoose.model('posts', lists); 

show.jade

 extends layout block content .show h1 #{post.title} p.meta Posted in a(href='/categories/show/#{post.category}') #{post.category} span by a(href='/posts/show/#{post.author}') #{post.author} on #{moment(post.date).format("DD-MMM-YYYY")} img(src='/images/uploads/#{post.mainimage}') !=post.body br hr 

产量

596e795be0a91a1cdcc572eb
空值

我一直被困在这个错误很长一段时间。 阅读并尝试所有可能的解决scheme在这个网站。 甚至经过了mongoose的文档。 我不知道我做错了什么。 请帮忙。谢谢