title: Most efficient way to store nested categories (or hierarchical data) in Mongo?
body: <p>We have nested categories for several products (e.g., <strong>Sports -> Basketball -> Men's</strong>, <strong>Sports -> Tennis -> Women's</strong> ) and are using Mongo instead of MySQL.</p>
  
  <p>We know how to store nested categories in a SQL database like MySQL, but would appreciate any advice on what to do for Mongo. The operation we need to optimize for is quickly finding all products in one category or subcategory, which could be nested several layers below a root category (e.g., all products in the <strong>Men's Basketball</strong> category or all products in the <strong>Women's Tennis</strong> category).</p>
  
  <p><a href="https://docs.mongodb.com/manual/applications/data-models-tree-structures/" rel="noreferrer">This Mongo doc</a> suggests one approach, but it says it doesn't work well when operations are needed for subtrees, which we need (since categories can reach multiple levels).</p>
  
  <p>Any suggestions on the best way to efficiently store and search nested categories of arbitrary depth?</p>