如果我在我的架构中有像这样的嵌入文档:
location: {
coordinates: [-41.588221, 71.123812],
unitNumber: '4a',
streetAddress: '1 Abc Lane',
<Other location-related data>
}
我要排除的文件和其他使用$nin
位置的基础上,但我只有unitNumber
和coordinates
,有没有办法正确做到这一点。
例如,说我想排除从结果集的位置下面的数组:
locations = [
{coordinates: [-41.2342432, 71.812312], unit: '4a'},
{coordinates: [-40.2242432, 70.212352], unit: '7d'},
{coordinates: [-42.2546432, 72.312312], unit: '10b'},
{coordinates: [-41.2342132, 61.812312], unit: '1z'}
]
有没有办法做到这一点给出了上述模式?我不相信使用{location: {$nin: locations}}
会起作用,因为它要求locations
中的每个对象都要使整个嵌入式文档符合排除条件。
这工作完美,谢谢!也担心'$ nin'的表现,所以我很高兴这是解决方案:) – jtmarmon 2014-12-08 21:57:14