Skip to content

Meta Requests

Denis Koljada edited this page Sep 26, 2021 · 8 revisions

Syncmesh stores metadata in the MongoDB instance, most importantly available external nodes and data regarding the own node. This data can be used to query nodes without specifying external IPs (use_meta parameter in the default request), and aggregation/collection with radius geofencing is possible.

General structure

A meta request has the following parameters:

  • "meta_type": specifies the meta request type. Can be either "get", "update" or "delete"
  • "id": specifies the relevant Node ID. Optional, only relevant for "update" or "delete"
  • "node": the node json object to modify/create. Optional, only relevant for "update"

Updating or creating new node entries

If you do not specify the ID or MongoDB can't find it, a new node will be created:

{
  "meta_type": "update",
  "node": {
    "address": "http://some.ip.here",
    "lat": 43,
    "lon": 43,
    "subscribed": true,
    "own_node": true
  }
}

If you want to update instead of creating, specify the relevant parameters and the ID:

{
  "meta_type": "update",
  "id": "614f2c3cd9b5863f8ec035b1",
  "node": {
    "address": "http://some.ip.here/",
    "lon": 41,
    "subscribed": true,
    "lat": 42,
    "own_node": false
  }
}

It is important you pass all parameters when updating the node, otherwise, those not mentioned get set to 0/false/"". The id in the example above is just an example hex value.

Deleting Nodes

Deleting works by just specifying the ID:

{
  "meta_type": "delete",
  "id": "document_id_here"
}

Fetching Nodes

You can also fetch the array of all saved nodes with a simple:

{"meta_type": "get"}
Clone this wiki locally