1 var Commidity = require("./Model/commiditiesModel"); 2 function search(response,request,key){ 3 var search = new RegExp(key); 4 var query = { "title": search} 5 console.log(query); 6 Commidity.find(query,function(err, articles) { 7 if (err) return console.error(err); 8 console.dir(articles); 9 response.writeHead(200, {"Content-Type": "application/json"}); 10 response.write(JSON.stringify(articles)); 11 response.end(); 12 }); 13 } 14 15 exports.search = search;