My site will have many products, and each product would have many tags (imagine wordpress’s tag option)
What’s the best way to organize these in the database?
Please suggest me some tutorials if there’s any.
Hi @Ishmam_N_A ,
Welcome to MongoDB community.
The classic way to store it is via an embedded array of tags:
{
PictureUrl: ...,
tags: [ "party", "man" ... ]
}
As long as number of tags is below a few houndreds its fine.
You can index tags field with multi key index and simply search terms on tags.
Updating array is simply done with array operators
Thanks
Pavel
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.