質問

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