I want to reduce number of reads in order to get Question's detail from QuestionCollection
(Array of Questions) .
My app works like a part of stackoverflow.
I want to show how many likes, views and comments do a question have . So in order to handle this I created multiple collection like
QuestionCollection
CommentCollection
QuestionLikes
QuestionViews
QuestionTAG
I thought that CommentCollection (comments) only belongs to a question. So I am thinking of incorporating in QuestionCollection
like an array(s) or collection(But it requires another read hit). which one is better ?
And I think of adding two variable's(totalViews,totalLikes
) to QuestionCollection. But each time I must have to check whether this question is liked by this user or view by this user.
Give me a suggestion or an alternative so I can have the least hit to fetch question details.
Edit
For Showing View Count
I iterate and count QuestionViews Collection where questionID == myQuestionID
For Showing Likes Count
I iterate and count QuestionLikes Collection where questionID == myQuestionID
why I don't add it to QuestionCollection? Because I want to show most Viewed and most like question like stackoverflow. If i add it to QuestionCollection How could I know the most like and most Viewed question.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…