In my models I have this
module.exports.getPhotosById = function(userId,callback){
Photos.findOne({userId:userId},callback);
}
Then in route I do
Photo.getPhotosById(req.user._id,function(err,result){
console.log(result);
console.log(result.length);
});
The first console output this
{ _id: 325657865435643245,
userId: '32443564',
photo: 'abc.jpg',
caption: 'abc'
}
but why it's not an array? because the second console's output is undefined.