Data model

Normally you don't need to access MongoDB directly as Orion Contex Broker uses it transparently. However, for some operations (e.g. backup, fault recovery, etc.) it is useful to know how the database is structured. This section provides that information.

In the case you need to access database directly, be very careful when manipulation it, as some actions could be irreversible (doing a backup at the beginning it's a good idea).

Orion Context Broker uses four collections in the database, described in the following subsections.

entities collection

The entities collection stores information about NGSI entities. Each document in the collection corresponds to an entity.

Fields:

Example document:

 {
   "_id":
       "id": "E1",
       "type": "T1",
       "servicePath": "/"
   },
   "attrs": {
       "A1": {
           "type": "TA1",
           "value": "282",
           "creDate" : 1389376081,
           "modDate" : 1389376120,
           "md" : [
              { 
                 "name" : "customMD1",
                 "type" : "string",
                 "value" : "AKAKA"
              },
              {
                 "name" : "customMD2",
                 "type" : "integer",
                 "value" : "23232"
              }
           ]
       },
       "A2_ID101": {
           "type": "TA2",
           "value": "176",
           "creDate" : 1389376244,
           "modDate" : 1389376244
       },
       "position": {
           "type": "location",
           "value": "40.418889, -3.691944",
           "creDate" : 1389376244,
           "modDate" : 1389376244
       }
   },
   "attrNames": [ "A1", "A2", "position" ],
   "creDate": 1389376081,
   "modDate": 1389376244,
   "location": {
       "attrName": "position",
       "coords": {
           "type": "Point",
           "coordinates": [ -3.691944, 40.418889 ]
       }
   }
 }

registrations collection

The registrations collection stores information about NGSI9 registrations. Each document in the collection corresponds to a registration.

Fields:

Example document:

 {
   "_id": ObjectId("5149f60cf0075f2fabca43da"),
   "fwdRegId": "5149f60cf0075f241bca22f1",
   "expiration": 1360232760,
   "contextRegistration": [
       {
           "entities": [
               {
                   "id": "E1",
                   "type": "T1",
                   "isPattern": "false"
               },
               {
                   "id": "E2",
                   "type": "T2",
                   "isPattern": "false"
               }
           ],
           "attrs": [
               {`\
                   "name": "A1",
                   "type": "TA1",
                   "isDomain": "false"
               },
               {
                   "name": "A2",
                  "type": "TA2",
                   "isDomain": "true"
               }
           ],
           "providingApplication": "http://foo.bar/notif"
      },
  ]
 }

csubs collection

The csubs collection stores information about NGSI10 subscriptions. Each document in the collection corresponds to a subscription.

Fields:

Example document:

 {
   "_id": ObjectId("5149fd46f0075f83a4ca0300"),
   "expiration": 1360236300,
   "lastNotification": 1360232700,
   "throttling": 10,
   "reference": "http://notify.me",
   "entities": [
       {
           "id": "E1",
           "type": "T1",
           "isPattern": "false"
       }
   ],
   "attrs": [
        "A1",
        "A2"
   ],
   "conditions": [
       {
           "type": "ONTIMEINTERVAL",
           "value": 60
       },
       {
           "type": "ONCHANGE",
           "value": [
               "A1",
               "A2"
           ]
       }
   ],
   "count": 27,
   "format": "JSON"
 }

casubs collection

The casubs collection stores information about NGSI9 subscriptions. Each document in the collection corresponds to a subscription.

Fields:

Example document:

 {
   "_id": ObjectId("51756c2220be8dc1b5f415ff"),
   "expiration": 1360236300,
   "reference": "`[`http://notify.me`](http://notify.me)`",
   "entities": [
       {
           "id": "E5",
           "type": "T5",
           "isPattern": "false"
       },
       {
           "id": "E6",
           "type": "T6",
           "isPattern": "false"
       }
   ],
   "attrs": [
       "A1",
       "A2"
   ],
   "lastNotification" : 1381132312,
   "count": 42,
   "format": "JSON"
 }