title: MongoDB returning empty array
body: <p>I'm trying to populate albums with images using userid sent through params but i end up with an empty array even though there is data in database.</p>
  
  <pre><code>"use strict"
  var express = require('express');
  
  var app = express();
  var mongoose = require('mongoose');
  var Schema = mongoose.Schema
  
  console.log('Welcome');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  
  mongoose.connect('mongodb://localhost/Datab');
  var db = mongoose.connection;
  
  db.once('open', function () {
      console.log('Connected to Database');
  
  });
  
  //Schema for the data 
  
  var userSchema = new mongoose.Schema({
      name: String
  });
  var albumSchema = new mongoose.Schema({
      userid: String,
      albumName: String,
      albumDesc: String,
      albumThumbnail: String,
      imageCount: Number,
      images: [{
          type: Schema.Types.ObjectId,
          ref: 'Image'
      }]
  });
  
  var ImageSchema = new Schema({
      album_id: {
          type: String,
          ref: 'Album'
      },
      imageName: String,
      imageDescription: String,
      imageURL: String,
      likeCount: Number,
      commentCount: Number
  })
  
  
  var Userdata = mongoose.model('Userdata', userSchema);
  var Album = mongoose.model('Album', albumSchema);
  var Image = mongoose.model('Image', ImageSchema);
  
  //display of albums
  app.get('/user/:user_id/photos', function (req, res) {
      var user_id = req.params.user_id
      Album.find({
          userid: user_id
      })
          .populate('images')
          .exec(function (err, albums) {
              if (!err) {
                  return res.send({
                      status: {
                          error: 0,
                          message: "Successful"
                      },
                      data: {
                          albums: albums
                      }
                  })
              } else
                  res.send('Unsuccessful');
          })
  
  
  });
  
  
  app.listen(3000);
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>{
  
      "status": {
  
          "error": 0,
  
          "message": "Successful"
  
      },
  
      "data": {
  
          "albums": []
  
      }
  
  }
  </code></pre>
  
  <p>why do i get an empty array as output?</p>
  
  <p>Find in the mongo shell returns the following result</p>
  
  <pre><code>db.Album.find() {
      "_id": ObjectId("529eed506c7b0a09b2204203"),
      "albumDesc": "outings",
      "albumName": "Photoclics1",
      "albumThumbnail": "http: //192.168.71.250/uploads/cat1_thumb.jpg",
      "imageCount": "1",
      "images": ["529ef0016c7b0a09b2204205", "529ef0266c7b0a09b2204206"],
      "userid": "529eec5a6c7b0a09b22041ff"
  }
  </code></pre>
  
  <p>EDIT 2: This is the output that i expect to get</p>
  
  <pre><code>{
  "error": {
  "status": 0,
  "message": "Successful"
  },
  "data": {
  "albums": [
  {
  "albumName": "myclicks",
  "albumID": "527102fdaed86d8807000001",
  "albumDescription": "PhotosIclicked",
  "albumThumbnailURL": "http: //192.168.71.250/uploads/image.jpg",
  "imageCount": 2,
  "images": [
  {
  "imageID": "527102fdaed86d8807000001",
  "imageName": "mycat",
  "imageDescription": "billy",
  "imageURL": "http: //192.168.71.250/uploads/cat.jpg",
  "imageThumbnailURL": "http: //192.168.71.250/uploads/cat_thumb.jpg",
  "likeCount": 21,
  "commentCount": 1
  },
  {
  "imageID": "527102fdaed86d8807000001",
  "imageName": "mycat",
  "imageDescription": "billy",
  "imageURL": "http: //192.168.71.250/uploads/cat1.jpg",
  "imageThumbnailURL": "http: //192.168.71.250/uploads/cat1_thumb.jpg",
  "likeCount": 21,
  "commentCount": 1
  }
  ]
  }
  ]
  }   
  </code></pre>