所以,我正在使用mongo db 2.6。我的收藏结构如下:
{
_id: '1',
items: [
{index: '1', value: 'pretty'},
{index: '1-section', value: 'good'},
{index: '2', value: 'ugly'},
{index: '2-section', value: 'bad'},
]
},
{
_id: '2',
items: [
{index: '1', value: 'pretty'},
{index: '1-section', value: 'good'},
{index: '2', value: 'beautifull'},
]
}
如您所见,items
持有一个对象数组,每个对象都有一个对应的“section”对象。
我的目标是找到项目没有相应对象的文档。输出样本:
{
_id: '2',
items: [
{index: '1', value: 'pretty'},
{index: '1-section', value: 'good'},
{index: '2', value: 'beautifull'},
]
}
命名模式是{index} -section。
我用javascript脚本来实现这一点,但是collection
非常大,并且它不能像我需要的那样快。
非常感谢您的帮助。