I cannot manage to get this to work:
db.library.update({
categories: {
$all: ['/movie/action', '/movie/comedy'],
$nin: ['/movie/cartoon']
},
location: {
$geoWithin: {
$centerSphere: [[48.8574946, 2.3476296000000048], 50/6378.1]
}
}
},
{
$setOnInsert: {
categories: ['/movie/action', '/movie/comedy'],
location: {
type: 'Point',
coordinates: [48.8574946, 2.3476296000000048]
}
},
$addToSet: {users: {_id: '1', date: '2018-04-06'}}
},
{ upsert: true })
It returns the following error:
cannot infer query fields to set, path 'categories' is matched twice
I understand that query part is moved to update part when upsert happens, but I'm not sure how to keep $all
from having this effect
It does work when $all
array is not set to more than 1 element.
答案 0 :(得分:0)
我找到了这个解决方案,即使被迫在v3
下列出v4
元素很痛苦:
$all
欢迎任何更简单的解决方案