Hello everyone.
On this section when using the populate() function to show the referenced object it does not show as it is shown in the video. The doc containing the author object shows as [model] instead of the complete object. In the video it shows the full Author object shown using this method.
(cannot show image due to new user limitation).
My result (the result is also different of how it is shown in the video but which is asked on another thread).
The code in question:
async function listCourses() {
const courses = await Course.find()
.populate("author", "name -_id")
.select("name author");
console.log(courses);
The models:
const Author = mongoose.model(
"Author",
new mongoose.Schema({
name: String,
bio: String,
website: String,
})
);
const Course = mongoose.model(
"Course",
new mongoose.Schema({
name: String,
author: {
type: mongoose.Schema.Types.ObjectId,
ref: "Author",
},
})
);
I am using Nodejs version 16.13.2, npm version 8.1.2, and mongoose is the same as the video which is 5.0.3.