O
O
olezhenka2018-07-02 17:01:11
MongoDB
olezhenka, 2018-07-02 17:01:11

Is this pattern normal?

Create a collection with VK publics and store all posts from the public in it, which can be more than 50k. Getting a public document with all 50k posts will of course heavily load the RAM in the nodejs application, but if I make a filter, as a result of which there will be 100 posts in the output array, and if I need data about the public itself, then I will simply hide receiving posts.
Will it be normal or is it better to store publics and their posts in different collections?

const publicsSchema = new Schema(
  {
    group_id: Number,
                posts: [
                  {
                    post_id: Number,
                    date: Number,
                    ...
                  }
                ]
  }
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zxscv, 2018-07-02
@olezhenka

It is better to store posts in one heap along with the group_id property. And another collection will store all group data except posts

const postsSchema = new Schema(
  {
                    post_id: Number,
                    groupId:Number,
                    date: Number,
                    ...
  }
)

const groupSchema = new Schema(
  {
                    groupId:Number,
                    ...
  }
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question