【发布时间】:2016-02-11 13:25:22
【问题描述】:
我在 Orion 上下文代理中有许多实体,例如以下实体。 user_id 属性用于区分不同用户生成的实体。
{
"_id": {
"id": "customCommands",
"type": "Command",
"servicePath": "/"
},
"attrNames": ["command", "user_id"],
"attrs": {
"command": {
"type": "string",
"creDate": 1455195329,
"modDate": 1455195329,
"value": "RASPBERRY_ID"
},
"user_id": {
"type": "string",
"creDate": 1455195329,
"modDate": 1455195329,
"value": "e260d1c6-f39e-4257-9f3e-91a82b281772"
}
},
"creDate": 1455195329,
"modDate": 1455195329
}
我想根据 user_id 属性的值删除一些此类实体。我尝试使用如下过滤功能(restriction 元素)来指定希望删除其实体的用户。 json 发布到 http://my_ip:my_port/v1/updateContext/,我指定了以下标题:Accept: application/json 和 Content-Type: application/json
{
"contextElements": [{
"type": "Command",
"id": "customCommands"
}],
"restriction": {
"scopes": [{
"type": "FIWARE::StringQuery",
"value": "user_id==e260d1c6-f39e-4257-9f3e-91a82b281772"
}]
},
"updateAction": "DELETE"
}
但是,我收到以下错误。
{
"errorCode": {
"code": "400",
"reasonPhrase": "Bad Request",
"details": "JSON Parse Error: unknown field: /restriction"
}
}
是我做错了什么,还是限制对删除实体不起作用?如果是这种情况,我该怎么办?
【问题讨论】:
-
我绕过了这个问题,将 user_id 使用分隔符移动到实体 id,如下所示,然后根据新 id 删除。
{ "_id": { "id": "customCommands|e260d1c6-f39e-4257-9f3e-91a82b281772", "type": "Command", "servicePath": "/" }, "attrNames": ["command", "user_id"], "attrs": { "command": { "type": "string", "creDate": 1455195329, "modDate": 1455195329, "value": "RASPBERRY_ID" } }, "creDate": 1455195329, "modDate": 1455195329 }
标签: json messagebroker fiware-orion