I
I
IvanIvanIvanIvanIvan2020-05-15 21:33:50
MongoDB
IvanIvanIvanIvanIvan, 2020-05-15 21:33:50

How to set up a base. Linking collections?

For example, I have a product document:

{
   name: 'Cушилка"
   company: ['id231231313', 'id223234234']
}


Is it correct to write in the array all the id of the companies that sell this dryer? How then to request all these companies, sort them. And what if this dryer will be sold by 5,000 or 10,000 companies. How to deal with it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RaShe, 2020-05-21
@RaShe

On a side note:
It is better not to store in the product document something that is not very related to the product. It is better to put the links in a separate collection or write the product ID in the company's collection (which is also not very good).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question