I need to present the timeline of his activities to the user.
Now there are two options. One is,
The disadvantage of putting the user’s activities in the user collection is that there may be a lot of things.
Another solution is,
Create a new activities collection and use userId as index.
But in fact, I don’t need to watch the activities of multiple users at the same time.
For your needs, it is recommended to add another collection and use userId for association, although mongodb gives priority to embedding. Analysis of your activities since it is used to do the user’s activity timeline, it is basically every user should have. In addition, according to your description, activities will put a lot of things. although mongodb currently extends its size to 16M for a single doucment, if the content is too large, it will still exceed its limit, and will also have some influence on queries, etc. In this case, mongodb also suggests making redundant connections to simulate SQL connection queries.