【问题标题】:FIWARE Orion: how to add creDate and modDate to notification from orion?FIWARE Orion:如何将 creDate 和 modDate 添加到来自 Orion 的通知?
【发布时间】:2017-03-10 10:31:23
【问题描述】:

我正在尝试使用 subscribeContext 并通知(请参阅链接 https://fiware-orion.readthedocs.io/en/master/user/walkthrough_apiv1/index.html#ngsi10-standard-operations

和 mongodb 一样,有 creDate 和 modDate 属性,但在 notifyContextRequest payload 中没有这两个属性。

是否可以在 notifyContextRequest 负载中包含 creDate 和 modDate 属性?

有没有什么方法可以使用 Orion 方法获取这些属性?

详情请见下文: 一行一个mongodb:

{
    "_id" : {
        "id" : "sb1_dv1_5",
        "type" : "Call",
        "servicePath" : "/"
    },
    "attrNames" : [ 
        "status", 
        "type", 
        "to"
    ],
    "attrs" : {
        "status" : {
            "type" : "string",
            "creDate" : 1488876118,
            "modDate" : 1488876118,
            "value" : "open",
            "mdNames" : []
        },
        "type" : {
            "type" : "string",
            "creDate" : 1488876118,
            "modDate" : 1488876118,
            "value" : "video",
            "mdNames" : []
        },
        "to" : {
            "type" : "string",
            "creDate" : 1488876118,
            "modDate" : 1488876118,
            "value" : "police",
            "mdNames" : []
        }
    },
    "creDate" : 1488876118,
    "modDate" : 1488876118
}

非常感谢。

【问题讨论】:

    标签: mongodb fiware fiware-orion


    【解决方案1】:

    如果您使用的是最新的 Orion 版本之一(我认为它是在 1.5.0 中引入的),您可以在创建订阅时在 notification 内的 metadata 字段中使用 dateCreateddateModified,例如:

    POST /v2/subscriptions
    
    {
       ...
       "notification": {
          ...
          "metadata": [ "dateCreated", "dateModified", "*" ]
          ...
       }
       ...
    }
    

    查看NGSIv2 latest specification 的“过滤属性和元数据”部分 abd“系统/内置元数据”以了解更多详细信息。

    更新: 以上指的是 dateCreated 和 dateModified 元数据(具有属性的创建和修改日期)。如果您想要 dateCreated 和 dateModified attributes(具有整个实体的创建和修改日期),它以类似的方式添加,但使用 attrs 字段,例如:

    POST /v2/subscriptions
    
    {
       ...
       "notification": {
          ...
          "attrs": [ "dateCreated", "dateModified", "*" ]
          ...
       }
       ...
    }
    

    查看NGSIv2 latest specification 的“过滤属性和元数据”部分 abd“系统/内置属性”以了解更多详细信息。

    【讨论】:

    • 我正在使用 { "orion": { "version": "1.3.0", "uptime": "10 d, 7 h, 0 m, 51 s", "git_hash": " cb6813f044607bc01895296223a27e4466ab0913”,“compile_time”:“2016 年 9 月 2 日星期五 08:19:12 UTC”,“compiled_by”:“root”,“compiled_in”:“ba19f7d3be65”} }
    • 有什么方法可以使用 Orion 方法获取这些属性?
    • 首先,您应该更新 Orion(至少到 1.5.0,尽管我建议暂时使用最新版本,即 1.7.0)。其次,不确定“猎户座方法”是什么意思?您是否参考了如何使用对 Orion 的查询(即不是订阅)来获取 dateCreated/dateModified?
    • 首先,非常感谢 fgalan。对于第二件事,我的意思是如果没有办法使用订阅添加 dateCreated 和 dateModified。我们有什么方法可以使用 queryContext 或其他 orion 方法获取 dateCreated、dateModified 吗?
    • 我试过你的方法。它现在正在工作。谢谢你值得回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多