Untitled
raw download clone
TEXT
views 33
,
size 664 b
app.get('/getData', function(req, res) {
   
  
  console.log(req.query);
  
  

  var MongoClient = require('mongodb').MongoClient;
  var url = "mongodb://127.0.0.1:27017/";

  MongoClient.connect(url, function(err, db) {
    if (err) throw err;
    var dbo = db.db("topicos_hardware");
    var myobj = req.query;


    dbo.collection("dados").findOne(myobj, function(err, result) {
      if (err) throw err;
      // console.log("1 document inserted");
      db.close();

      if (!result){
        res.send("not found");
      }else{
        res.send(result);
      }

      
    });


  });


  // res.send("not found");
});
close fullscreen
Login or Register to edit or fork this paste. It's free.