How to find one document in MongoDB by unique slug from Next.js?

Viewed 32

My MongoDB data looks like this:

[
  {
    "Post": "this is a post",
    "_id": ObjectId("630f3c32c1a580642a9ff4a0"),
    "slug": "this-is-a-title",
    "title": "This is a title"
  },
  {
    "Post": "this is a post",
    "_id": ObjectId("630f3c32c1a580642a9ff4a1"),
    "slug": "this-is-a-title-b",
    "title": "This is a title B"
  }
]

All slug are unique, how can I find one document by that unique slug?

I am not using Mongoose.

1 Answers
Related