mongoskin,expressjs,req.params只给我回名字

mongoskin,expressjs,req.params只给我回名字,express,mongoskin,Express,Mongoskin,我是nodejs的新手,从两天以来我一直在试图弄清楚它是如何与mongoskin和express一起工作的,但不知为什么我没有运气。 需要人帮忙。我需要编辑收藏 router.get('/edit/:name', function(req, res){ var db = req.db; var n = req.params; console.log(n); // will only output the selected name. if(!n){res.send('not found quer

我是nodejs的新手,从两天以来我一直在试图弄清楚它是如何与mongoskin和express一起工作的,但不知为什么我没有运气。 需要人帮忙。我需要编辑收藏

router.get('/edit/:name', function(req, res){
var db = req.db;
var n = req.params;
console.log(n); // will only output the selected name.
if(!n){res.send('not found query')}
else{
   db.collection('uList').find(n, function(err, docs){
       res.json(docs);
   });
  };
});
这是我的收藏:

{"_id": ObjectId("1341354563458567845678"), "name": "fritz", "age": 19, "info": "fritz was here"}
{"_id": ObjectId("9676524234861346897543"), "name": "Susi", "age": 21, "info": "Susi was here too"}
hier是我的app.js

var mongo = require('mongoskin');
var db = mongo.db('mongodb://localhost:27017/sample', {native_parser:true});
输出将只返回名称

{"name": "fritz"}
非常感谢您的帮助。

已解决!! 如果有人像我一样有问题,试试这个

db.collection('uList').find(n).toArray(function(err, n){
   res.json(n);
});
将得到这样的输出

{"_id": ObjectId("9676524234861346897543"), "name": "Susi", "age": 21, "info": "Susi was here too"}
谢谢