title: MongoDB data return []
body: <p>I'm making a project for my college assignment, but I'm having a trouble while i'm trying to get a data from database called 'project' in 'sitelist' collection from MongoDB.
  But for some reason the data i got is only an empty array [ ].</p>
  
  <p>I'm new to MongoDB so i want to know where did i do wrong. </p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const mongoose = require('mongoose');
  const app = express();
  const SLDBModel = require('./sldb_schema');         
  require('./db');
  
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(express.urlencoded({ extended: true }))
  
  app.use(function (req, res, next)
  {
      res.setHeader('Access-Control-Allow-Origin','*');
      res.setHeader('Access-Control-Allow-Methods','GET, POST, PUT, DELETE');
      res.setHeader('Access-Control-Allow-Headers','content-type, x-access-token');
      res.setHeader('Access-Control-Allow-Credentials', true);
      next();
  });
  
  app.get('/api/getList', function (req, res){   
      SLDBModel.find({},function(err, data){
          if(err){
              console.log('//app.get// getList error!...');
              res.send(err);
          }
          else{   
              console.log(data);
              res.send(data.map(v =&gt; v.toJSON()));
          }
      });
  });
  
  module.exports = app;
  
  app.listen(3000, ()=&gt;{
      console.log("SERVER IS ONLINE! ON PORT 3000");
  })
  </code></pre>
  
  <p><strong>sldb_schema.js</strong></p>
  
  <pre><code>var mongoose = require('mongoose');
  const Schema = mongoose.Schema;
  
  const SLSchema = new Schema({
          S_NAME: {type: String, required: true},
          S_ADD: {type: String, required: true},
          S_STATUS: {type: String, required: true}
      }
  );
  
  const SLDBSchema = new Schema({
          list: [SLSchema]
      }
  );
  
  const SLDBModel = mongoose.model('sitelist', SLDBSchema);
  module.exports = SLDBModel;
  </code></pre>
  
  <p><strong>db.js</strong></p>
  
  <pre><code>var mongoose = require('mongoose');
  
  mongoose.connect('mongodb://127.0.0.1/project', {useUnifiedTopology: true, useNewUrlParser: true });
  
  mongoose.connection.on('connected', function () {
      console.log('MONGOOSE default connection open');
  });
  mongoose.connection.on('error', function (err) {
      console.log('MONGOOSE default connection error: ' + err);
  });
  mongoose.connection.on('disconnected', function () {
      console.log('MONGOOSE default connection disconnected');
  });
  process.on('SIGINT', function () {
      mongoose.connection.close(function () 
      {
          console.log('MONGOOSE default connection disconected through app termination');
          process.exit(0);
      });
  });
  
  </code></pre>
  
  <p><strong>Data in database called 'project' in collection 'sitelist'</strong> </p>
  
  <pre><code>{
      "_id" : ObjectId("5ec4672e44f01dcae82c3dde"),
      "error" : "0",
      "num_rows" : 3,
      "list" : [ 
          {
              "S_NAME" : "SBOBETH",
              "S_ADD" : "sbobeth.com",
              "S_STATUS" : "UP"
          }, 
          {
              "S_NAME" : "GTRCASINO",
              "S_ADD" : "gtrcasino.com",
              "S_STATUS" : "DOWN"
          }, 
          {
              "S_NAME" : "SBOBETH",
              "S_ADD" : "sbobeth.com",
              "S_STATUS" : "DOWN"
          }, 
          {
              "S_NAME" : "GTRBETCLUB",
              "S_ADD" : "gtrbetclub.com",
              "S_STATUS" : "UP"
          }, 
          {
              "S_NAME" : "77UP",
              "S_ADD" : "77up.bet.com",
              "S_STATUS" : "UP"
          }, 
          {
              "S_NAME" : "DATABET88",
              "S_ADD" : "databet88.net",
              "S_STATUS" : "DOWN"
          }, 
          {
              "S_NAME" : "FAFA855",
              "S_ADD" : "fafa855.com",
              "S_STATUS" : "UP"
          }
      ]
  }
  </code></pre>