2012-09-06 53 views
0

夥計們我正面臨着以下不相關的錯誤。nodejs中的匿名錯誤mongodb

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"> 

請幫我這個error.I得到這個錯誤同時通過URL以及href訪問它。

+0

僅供參考 - ObjectID在MongoDB中爲12個字節 - 是否有任何地方可以將奇怪的東西傳遞給ObjectID構造函數或類似的東西? –

+0

是的亞當我得到了你。事實上,我寫了搜索模塊之後,那裏的objectId passings.So我把它移到上面,它的工作。謝謝!!!! – Nilesh

+1

如果您將自己的答案與可接受的細節結合起來,請相信 - 它可能會在未來幫助其他人。 –

回答

0

是啊實際上搜索模塊寫在ID字段下,所以它無法執行任何操作。