Hi there,
I’m just starting out and experimenting with MongoDB, and I wanted to get an idea of whether I can improve what I have in mind. I’m working on a personal project for a pet shop e-commerce website, and I’ll have the following “tables”/documents: Animals, Products, and Users.
My users can be connected to multiple animals, and my products can also be associated with several animals. So, when I display products to the user, I want to prioritize showing products related to the animals they own. The approach I came up with is as follows:
User: {
id
Animals[Object…]
}
Product: {
id
Animals[Object…]
}
Animals:{
id
Products[Object…]
User[Object…]
}
However, I’m a bit unsure if this is the best way to go about it. I’m not sure if there might be a more efficient way to perform the query I want. ![]()