title: Mongo Database Fixing Names after Mongoose Index?
body: <p>I had a very weird issue with the way Mongoose interacted with my Node and Mongo database.</p>
  
  <p>I was using express to create a basic get api route to fetch some data from my mongodb.</p>
  
  <p>I had a database called test and it had a collection call "billings"</p>
  
  <p>so the schema and route was pretty basic</p>
  
  <blockquote>
    <p>apiRouter.route('/billing/')</p>
  </blockquote>
  
  <pre><code>    .get(function(req, res) {
          Billing.find(function(err, billings) {
              if (err) res.send(err);
  
              // return the bills
              res.json(billings);
          });
      }); 
  </code></pre>
  
  <p>Where "Billing" was my mongoose schema. that simply had 1 object {test: string}</p>
  
  <p>This worked fine, I got a response with all the items in my mongo db called "billings" which is only one item {test: "success"}</p>
  
  <p>Next I created a collection called "historys"</p>
  
  <p>I setup the exact same setup as my billings.</p>
  
  <blockquote>
    <p>apiRouter.route('/historys/')</p>
  </blockquote>
  
  <pre><code>    // get all the history
      .get(function(req, res) {
          Historys.find(function(err, historys) {
              if (err) res.send(err);
  
              // return the history
              res.json(historys);
          });
      }); 
  </code></pre>
  
  <p>where again "Historys" was my mongoose schema. This schema was identical in setup to my billings since I didnt have any real data, the fields were the same, i just had it with a test field so the json object returned from both billings and historys should have been</p>
  
  <blockquote>
    <p>{ test: "success" }</p>
  </blockquote>
  
  <p>However, this time I didnt get any data back, I just got an empty object </p>
  
  <blockquote>
    <p>[].</p>
  </blockquote>
  
  <p>I went through my code multiple times to make sure maybe a capital got lost, or a comma somewhere etc, but the code was identical. the setup and formatting in my mongodb was identical. I went into robomongo and viewed the database and everything was named correctly.</p>
  
  <p>Except, I had 2 new collections now.</p>
  
  <p>My original : "Historys" AND a brand new collection "Histories"</p>
  
  <p>Once i fixed my api route to go look at Histories instead of Historys, I was able to get the test data successfully. I still however cannot pull data from Historys, its like it doesnt exist yet there it was in my robomongo console when I refreshed.</p>
  
  <p>I searched all my code for any mention of histories and got 0 results. Where did the system know to fix the grammar on my collection?</p>