MongoDB中记录商店这样获取基于类型和祖先场蒙戈DB记录
{_id:100,type:"section",ancestry:nil,.....}
{_id:300,type:"section",ancestry:100,.....}
{_id:400,type:"problem",ancestry:100,.....}
{_id:500,type:"section",ancestry:100,.....}
{_id:600,type:"problem",ancestry:500,.....}
{_id:700,type:"section",ancestry:500,.....}
{_id:800,type:"problem",ancestry:100,.....}
我想为了获取记录这样 第一记录,其祖先是零 那么所有的记录,其父母是我们搜索第一条记录,其类型为“问题” 那么所有的纪录,其父母为我们搜索第一条记录,其类型为“部分”
预计产量
{_id:100,type:"section",ancestry:nil,.....}
{_id:400,type:"problem",ancestry:100,.....}
{_id:800,type:"problem",ancestry:100,.....}
{_id:300,type:"section",ancestry:100,.....}
{_id:500,type:"section",ancestry:100,.....}
{_id:600,type:"problem",ancestry:500,.....}
{_id:700,type:"section",ancestry:500,.....}
您可能需要在这里使用多个查询来获得您想要的效果 – Sammaye 2013-05-11 13:57:31