Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-19273

FIWARE.Question.Tech.How to create different record for every update in FIWARE-STH Comet?.

    Details

      Description

      Created question in FIWARE Q/A platform on 22-02-2022 at 09:02
      Please, ANSWER this question AT https://stackoverflow.com/questions/71218728/how-to-create-different-record-for-every-update-in-fiware-sth-comet

      Question:
      How to create different record for every update in FIWARE-STH Comet?

      Description:
      I just started using FIWARE and I'm having trouble with the data I want to persist on MongoDB. I want to use STH Comet in minimal mode. I am using a Python script that creates my context data with a specific id and then updates certain attributes of this data. While I can't see any problem when I observe the JSON data from this script, and HTTP requests but MongoDB keeps only the last updated version of this data in the related collection. In addition, the "sth" labeled collections does not show up. However I can see the "credate" and "moddate" metadatas in attributes. But I need different records for every update.
      Here is the first POST request that I send to Orion to create context data:
      {"id": "urn:ngsi-ld:entity:001",
      "type": "Log",
      "a":

      {"type": "Datetime", "value": "17/09/2021"}

      ,
      "b":

      {"type": "Datetime", "value": "12:00:18.0"}

      ,
      "c":

      {"type": "Integer", "value": 49.51}

      ,
      "d":

      {"type": "Integer", "value": 175.35}

      ,
      "e":

      {"type": "Integer", "value": 24.25}

      ,
      "f":

      {"type": "Integer", "value": 999.1}

      ,
      "g":

      {"type": "Integer", "value": 85.87}

      ,
      "h":

      {"type": "Integer", "value": -0.01}

      ,
      "i":

      {"type": "Integer", "value": 37.41}

      ,
      "j": {"type": "Integer", "value": 60.65}}

      Here is what I get in MongoDB collection, attrNames has been made dummy for the question:
      {
      "_id":

      { "id": "urn:ngsi-ld:entity:001", "type": "Log", "servicePath": "/" }

      ,
      "attrNames": [
      "a",
      "b",
      "c",
      "d",
      "e",
      "f",
      "g",
      "h",
      "i",
      "j"
      ],
      "attrs": {
      "a":

      { "type": "Datetime", "creDate": 1645514416, "modDate": 1645514416, "value": "17/09/2021", "mdNames": [] }

      ,
      "b":

      { "value": "12:00:21.0", "type": "Datetime", "mdNames": [], "creDate": 1645514416, "modDate": 1645514597 }

      ,
      "c":

      { "value": 666.47, "type": "Integer", "mdNames": [], "creDate": 1645514416, "modDate": 1645514640 }

      ,
      "d":

      { "value": 175.55, "type": "Integer", "mdNames": [], "creDate": 1645514416, "modDate": 1645514597 }

      ,
      "e":

      { "value": 24.27, "type": "Integer", "mdNames": [], "creDate": 1645514416, "modDate": 1645514597 }

      ,
      "f":

      { "value": 999.28, "type": "Integer", "mdNames": [], "creDate": 1645514416, "modDate": 1645514597 }

      ,
      "g":

      { "type": "Integer", "creDate": 1645514416, "modDate": 1645514416, "value": 85.87, "mdNames": [] }

      ,
      "h":

      { "type": "Integer", "creDate": 1645514416, "modDate": 1645514416, "value": -0.01, "mdNames": [] }

      ,
      "i":

      { "type": "Integer", "creDate": 1645514416, "modDate": 1645514416, "value": 37.41, "mdNames": [] }

      ,
      "j":

      { "value": 1111.47, "type": "Integer", "mdNames": [], "creDate": 1645514416, "modDate": 1645514640 }

      },
      "creDate": 1645514416,
      "modDate": 1645514640,
      "lastCorrelator": "679e1cba-93b0-11ec-be0f-0242ac120102"

      This is the data output I can obtain with STH Comet Query:
      {
      "contextResponses": [
      {
      "contextElement": {
      "attributes": [
      {
      "name": "c",
      "values": [

      { "_id": "621ca977165813000740898e", "recvTime": "2022-02-28T10:52:39.012Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.47 }

      ,

      { "_id": "621ca97d165813000740899e", "recvTime": "2022-02-28T10:52:45.581Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.61 }

      ,

      { "_id": "621ca98316581300074089a7", "recvTime": "2022-02-28T10:52:51.239Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.46 }

      ,

      { "_id": "621ca98916581300074089ac", "recvTime": "2022-02-28T10:52:57.662Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.57 }

      ,

      { "_id": "621ca98d16581300074089b9", "recvTime": "2022-02-28T10:53:01.852Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.47 }

      ,

      { "_id": "621ca99316581300074089c7", "recvTime": "2022-02-28T10:53:07.242Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.41 }

      ,

      { "_id": "621ca9a116581300074089d2", "recvTime": "2022-02-28T10:53:21.305Z", "attrName": "c", "attrType": "Integer", "attrValue": 49.51 }

      ]
      }
      ],
      "id": "urn:ngsi-ld:entity:001",
      "isPattern": false,
      "type": "Log"
      },
      "statusCode":

      { "code": "200", "reasonPhrase": "OK" }

      }
      ]
      }

      As you can see, I can obtain the MongoDB _id in the returned query, but the problem is, I cannot find the location of these seperate datas in related MongoDB database.
      I've gone through all the docs but either couldn't find the solution or am I missing something in the architectural logic. How should I go about the issue?
      Thanks!

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2022-03-01 05:31|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2022-03-01 05:31|CREATED monitor | # answers= 0, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2022-03-05 05:31|UPDATED status: transition Answer| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2022-03-05 05:31|UPDATED status: transition Answer| # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2022-03-06 05:31|UPDATED status: transition Finish| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2022-03-06 05:31|UPDATED status: transition Finish| # answers= 1, accepted answer= True

          People

          • Assignee:
            Unassigned
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: