문제

What metrics should I use to decide whether I want to structure my document like:

{ count: { comments: Integer, views: Integer } }

vs.

{ commentCount: Integer, viewCount: Integer }

Since indexing count.comments vs. commentCount and querying on both is essentially equivalent, which structure would make sense in this situation?

도움이 되었습니까?

해결책

Typically that will depend on how many writes/reads you are going to perform over the collection, in the case of you're going to update the counts for views and comments very often I'd suggest to go with a plain approach, other downside is that I look for creating a child complex type is the level of verbosity, if creating those kind of objects are not completely required try to keep it as much simple as possible, the queries would be a lot of easier to implement in more complex scenarios.

my two cents.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top