title: Populate from two collections
body: <p>I have 2 Schemas defined for 2 different collections, and I need to populate one of them into the other:</p>
  
  <p>stationmodel.js</p>
  
  <pre><code>var stationSchema = new Schema({ 
      StationName: 'string', 
      _id: 'number', 
      Tripcount: [{ type: Schema.Types.ObjectId, ref: 'Tripcount'}]
  },
      {collection: 'stations'}
  );
  module.exports = mongoose.model('Station', stationSchema);
  </code></pre>
  
  <p>tripmodel.js</p>
  
  <pre><code>var tripSchema = new Schema({
      _id: { type: Number, ref: 'Station'},
      Tripcount: 'number'
  },
      {collection: 'trips'}
  );
  module.exports = mongoose.model('Tripcount', tripSchema);
  </code></pre>
  
  <p>According to the mongoose populate <a href="http://mongoosejs.com/docs/populate.html" rel="nofollow noreferrer">documentation</a>, this is the way to go. I have the problem that "Tripcount" remains as <code>[]</code> when I use Postman to GET the stations.</p>
  
  <p>My DB Structure for the 'stations' collection:</p>
  
  <pre><code>{
      "_id": 1,
      "StationName": "Station A",
  }
  </code></pre>
  
  <p>And for the 'trips' collection:</p>
  
  <pre><code>{
      "_id": 1,
      "Tripcount": 6
  }
  </code></pre>
  
  <p>My routes.js:</p>
  
  <pre><code>module.exports = function(app) {
  
      app.get('/stations', function(req,res) {
          var query = Station.find().populate('Tripcount');
          query.exec(function(err, stations){
              if(err)
                  res.send(err);
              res.json(stations);
          });
      });
  
  };
  </code></pre>
  
  <p>I can't seem to find the error, maybe someone here can spot a mistake I made.</p>