How to search against a deep tree-like structure in MongoDB? -
the simplest way explain situation standard filesystem structure close want accomplish:
folder - folder a2 -- file 1 -- file 2 - file 3 folder b - folder b2 - folder b3 -- file 4 folder has fields:
- _id - parents (in case there can multiple!) file has fields
- _id - targetfolder so, file deep in hierarchy.
how search , structure db efficiently can have deep folder hierarchies, of them having files.
i want able query returns every file under e.g. folder a. how this?
i recommend mongodb official documentation of topic. storing trees in database non trivial , every solution have pro , cons. experienced materialized paths model, efficient on hierachy search expensive on tree modification because have update every descendant node.
Comments
Post a Comment