find(...).populate is not a function in mongoose
I found the solution and was pretty easy. Seemed that I was really close yesterday.
I was doing the populate method in a collection doodleCollection
and I needed to do it in the model.
Changing the object that makes the find totally worked.
Instead of doodleCollection.find(...)
now I call doodleModel.find(...)
and populate is working perfect!
I was using following which gives me null as data:-
let PostModel = mongoose.model('Post');
Then I changed it as following and populate method worked:-
let PostModel = require("../model/post.js"); //path to your post model
Make sure you exported Model from your post.js model file like following:-
module.exports = mongoose.model('Post', PostSchema);