Skip to content
Justice Tech School

Project: Blog Data

Posts with embedded comments.

Example
db.posts.insertOne({
  title: "Hello",
  tags: ["intro"],
  comments: [{ by: "Zara", text: "Nice" }]
})
db.posts.updateOne({ title: "Hello" }, { $push: { comments: { by: "Kofi", text: "Hi" } } })

Exercise

Add comment.

{ : { comments: c } }

Quiz Test

Why embed comments?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.