title: Importing mongoDB collection to Express Model
body: <p>I currently have a collection named Consumer_Complaints sitting in a mongoDB database called consumer_Complaints (sorry for making that confusing). </p>
  
  <p>I can access the Consumer_Complaints collection via the mongo shell, but I am unable to access it in my application.  I am currently using express. </p>
  
  <p>Here is my code(Updated):</p>
  
  <pre><code>var mongoose = require("mongoose");
  
  //open connection to consumer_Complaints database
  
  mongoose.connect('mongodb://localhost/consumer_Complaints')
  
  //send error if connection fails
  mongoose.connection.on('error', console.error.bind(console, 'connection error:' ));
  
  var Schema = mongoose.Schema;
  
  var complaintSchema = new Schema({
      complaint_ID: String,
      product: String,
      sub_Product: String,
      issue: String,
      sub_Issue: String,
      state: String,
      zip_Code: String,
      submitted_Via: String,
      date_Received: String,
      date_sent_to_Company: String,
      company: String,
      company_Response: String,
      timely_Response: String,
      consumer_Disputed: String,
  });
  
  complaintSchema.set('collection', 'Consumer_Complaints');
  
  var model = mongoose.model("Model", complaintSchema)
  
  model.find({}, function (err, results) {
      res.json(results);
      console.log(results);//Your Json result
  });
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/5794834/how-to-access-a-preexisting-collection-with-mongoose">Previous Answer- Found Here</a>
  This seems to be what I want, but the syntax used is different than what I see in the mongoose documents, and when I try to replicate this, I get the following error. </p>
  
  <p>"TypeError: Cannot call method 'find' of undefined"</p>
  
  <p>Any help clarifying the top answer in the linked post, or figuring out what I'm doing wrong would be greatly appreciated!</p>