现在有两种方案一种是,
把用户的活动放在user collection里,缺点是可能会放很多东西
另一种方案是,
新建一张activities collection,用userId做index
但其实我并不需要同时看多个用户的activities
大家讲道理2017-04-21 11:18:18
For your needs, it is recommended to add another collection and use userId for association, although mongodb gives priority to inline processing. Since analyzing your activities is used to create a user activity timeline, it is basically something every user should have. In addition, according to your description, activities will put a lot of things. Although MongoDB currently expands the size of a single document to 16M, if the content is too large, it will still exceed its limit, and it will also have a certain impact on queries, etc. For this situation, mongodb will also recommend making redundant connections to simulate SQL connection queries.