title: I want to write data to mongodb Database using node.js
body: <p>Right now i am writing data to json file and getting that back to html page to display. Now i want to do same with mongodb Database. I have tried something but, it doesn't working.</p>
  
  <pre><code>app.get('/', function(req, res){
  url = 'http://www.amazon.in/Sony-Xperia-Z3-Copper-32GB/dp/B010V448ZC/ref=pd_rhf_se_s_cp_6?ie=UTF8&amp;dpID=419rmomR%2BjL&amp;dpSrc=sims&amp;preST=_SL500_SR135%2C135_&amp;refRID=19RT23W7T48Z99XNT6GK';
  
  request(url, function(error, response, html){
      if (!error) {
          var $ = cheerio.load(html)
          var json = {Product_Name : "", Brand : "", Color : "", Image : "", Price : "", Rating : ""};
  
          var P_name = $('#title').children().text();
          var brand = $('#brand').text();
          var color = $('.a-row').find('span.selection').text();
          var price = $('#price').find('span.a-size-medium').text();
          var rating = $('#averageCustomerReviews').find('span.a-icon-alt').text();
          var image = $('.imgTagWrapper').children().attr('src');
  
          /*json.Product_Name = P_name;
          json.Brand = brand.trim();
          json.Color = color.trim();
          json.Price = price.trim();
          json.Rating = rating.trim();
          json.Image = image.trim();
  
          fs.writeFile('output.json', JSON.stringify(json, null, 4), function(err){
              console.log('File successfully written! - Check your project directory for the output.json file');
          })*/
  
  
          var insertDocument = function(db, callback) {
             db.collection('proInfo').insertOne( {
  
                  "Product_Name": P_name,
                  "Brand":brand,
                  "Color":color,
                  "Price":price,
                  "Rating":rating,
                  "Image":image
  
             }, function(err, result) {
                  assert.equal(err, null);
                  console.log("Inserted a document into the proInfo collection.");
                  callback(result);
            });
          };
  
          MongoClient.connect(url, function(err, db) {
            assert.equal(null, err);
            insertDocument(db, function() {
                db.close();
            });
          });
  
          res.send('Check your console!')
      } else {
          console.log("We’ve encountered an error: " + error);
      }
  })
  })
  </code></pre>
  
  <p>It shows some error in console.log</p>
  
  <p>D:\Hemanth\Node Js\web scraper\node_modules\mongodb\lib\url_parser.js:20
      throw new Error('invalid schema, expected mongodb');
      ^</p>
  
  <p>Error: invalid schema, expected mongodb
      at module.exports </p>
  
  <p>Can anybody help me to fix this issue?</p>