伙计们我面临以下无关的错误。
500 Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
at Function.createFromHexString (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js:214:11)
at ArticleProvider.findById (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/articleprovider-mongodb.js:61:89)
at ArticleProvider.getCollection (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/articleprovider-mongodb.js:39:10)
at Db.collection (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/node_modules/mongodb/lib/mongodb/db.js:478:44)
at ArticleProvider.getCollection (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/articleprovider-mongodb.js:37:11)
at ArticleProvider.findById (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/articleprovider-mongodb.js:58:10)
at /home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/trucy-mongodb-express-node.js-blog-37daddd/app.js:63:21
at callbacks (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/node_modules/express/lib/router/index.js:272:11)
at param (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/node_modules/express/lib/router/index.js:246:11)
at param (/home/r121/Desktop/nilesh/cmarin-MongoDB-Node-Express-Blog-4a5e5e9/node_modules/express/lib/router/index.js:243:11)
虽然我只是调用看起来像这样的/blog/search
方法
app.get('/blog/search', function(req, res) {
res.render('blog_search.ejs', {
title: 'Search Contact',
});
});
我的blog_search.ejs
看起来像这样
<h1><%= title %></h1>
<form method="post" action="/blog/search">
<input type="text" name="title">
<input type="submit" name="submit">
请帮我解决这个错误。我在使用网址和a href访问时遇到此错误。
答案 0 :(得分:0)
是的,实际上搜索模块是在ID字段下编写的,因此它无法执行任何操作。