title: How to access a preexisting collection with Mongoose?
body: <p>I have a large collection of 300 <code>question</code> objects in a database <code>test</code>. I can interact with this collection easily through MongoDB's interactive shell; however, when I try to get the collection through Mongoose in an express.js application I get an empty array.</p>
  
  <p>My question is, how can I access this already existing dataset instead of recreating it in express? Here's some code:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var Schema = mongoose.Schema;
  
  mongoose.connect('mongodb://localhost/test');
  mongoose.model('question', new Schema({ url: String, text: String, id: Number }));
  
  var questions = mongoose.model('question');
  questions.find({}, function(err, data) { console.log(err, data, data.length); });
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>null [] 0
  </code></pre>