使用节点js在类似MongoDB中查询

我怎样才能使用nodejs在mongodb中做类似的查询:

这里是我的源代码,但它不起作用:

exports.findAll = function(req, res) { var country=req.params.country; db.collection('wines', function(err, collection) { collection.find({ 'country': new RegExp('/'+country+'/i') }).toArray(function(err, items) { res.jsonp(items); }); }); }; 

我解决了这样的问题:

  exports.findAll = function(req, res) { var country=req.params.country; db.collection('wines', function(err, collection) { collection.find({ 'country': new RegExp(country, 'i') }).toArray(function(err, items) { res.jsonp(items); }); }); }; 
Interesting Posts