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