Mongoose query return null
Mongoose pluralizes model names so it's running find
on the "blogposts" collection instead of "blogpost". That said, your query in the mongo shell is on the "blogmodel" collection. In that case:
var BlogModel = mongoose.Model("BlogModel", ..)
or pass the collection name as the third param:
var BlogModel = mongoose.model("BlogPost", schema, "blogmodel")
The first parameter to your BlogModel.find
callback is err
, the second parameter is docs
. So your code should be:
BlogModel.find({}, function(err, docs){
console.log(docs);
});