0

I need to list on my blog homepage one quite recent comment, the top author and 10 last articles (resume and authors list).

I think, instead of make multiple request in mongo database to get all the documents, I can just have a document containing all that data. Something like that :

{
    topAuthor: "",
    lastArticles: [{resume: "", authors: ["", ""]}...],
    lastComment: { user:"", content:"" }
}

I can update this document each time somebody post an article or when a user post a new comment if last comment is here since at least 1 hour. So there is no update intensive.

But the problem is that I only need one document like that. So, is it stupid to create a collection with just 1 document store inside ?

And sorry for my bad english, I'm french.
Thanks.

Community
  • 1
  • 1
jeremieca
  • 1,156
  • 2
  • 13
  • 38

1 Answers1

1

Note that if that document is the result of some query, you are implementing your own query cache this way.

I would have a look at this question about MongoDB and query caching:

And if you stick that doc in its own collection or keep it among other docs in another collection is a matter of convenience.

Community
  • 1
  • 1
mvw
  • 5,075
  • 1
  • 28
  • 34