我正在尝试从此mongodb文档中删除字段,但是pymongo select *
from (select
concat_ws(',',
if( adres1 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres1',NULL),
if( adres2 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres2',NULL),
if( adres3 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres3',NULL),
if( adres4 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres4',NULL),
if( adres5 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres5',NULL),
if( adres6 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres6',NULL),
if( adres7 LIKE '%Bruinbergstraat 2,Bruinberg,8730 Oedelem%','adres7',NULL)
) as 'matched_column_names',stamnummer
from alleclubs ) derived_table
where matched_column_names != '';
无法正常工作。我想念什么?
$unset
}
我尝试了其他堆栈溢出答案的各种解决方案和语法,但无济于事。
这在mongo shell中有效:
{
"_id" : ObjectId("5b7468c00f5f35010e8d37f9"),
"study_id" : 1,
"isActive" : true,
"credentials" : {
"access_token" : "eyJhbGciOiJIUzI1NiJ9",
"expires_in" : 28800,
"refresh_token" : "8e2d14c04207736cbb3afd9c83ba84fe73c51",
"user_id" : "22MDW2",
"scope" : [
"a",
"b",
"c",
"d"
],
"token_type" : "Bearer",
"expires_at" : 1534544517.06537
}
但这不适用于pymongo:
db.getCollection('users').update({'study_id': 1}, {$unset: {'credentials.user_id': 1}})
python 3.6
mongodb 4.0.1