Generic
Generic Access to Database Data.
The Generic controller provides "generic" access to database items without requiring specific database models for different database items. By providing the database item "_type" and the required item properties, you can query and modify database items.
Create
Create a generic data item.
Endpoint
POST /generic/create
Authorized User Role
user
Request Body
Field | Type | Required | Notes |
---|---|---|---|
_type | string | yes | Database item type. |
deviceId | string | Device ID owning the item. This must be a deviceId claimed by the app account of the authenticated user. | |
* | any | Item attributes to create. |
Query String Options
Field | Type | Default | Notes |
---|
Response
The created item.
Field | Type | Notes |
---|---|---|
_type | string | Database item type. |
* | any | Item attributes. |
Find
Find data items from a database table.
Endpoint
POST /generic/find
Authorized User Role
user
Request Body
Field | Type | Required | Notes |
---|---|---|---|
_type | string | yes | Database item type. |
deviceId | string | Device ID owning the item. | |
* | any | Optional item attributes to filter selected items. |
Query String Options
Field | Type | Default | Role | Notes |
---|---|---|---|---|
index | string | owner | Database index name: primary or gs1. | |
limit | number | Number of items to retrieve. | ||
next | object | Pagination token for the next page. | ||
prev | object | Pagination token for the previous page. |
Response
Paged response.
Field | Type | Notes |
---|---|---|
data | array | An array of devices owned by the user. |
next | string | Paged cursor to use for the next page of items. |
prev | string | Pages cursor to use for the previous page of items. |
Item
Field | Type | Notes |
---|---|---|
* | any | Item attributes. |
curl -X POST ${CLOUD_ENDPOINT}/tok/generic/find \
-H 'Authorization: ${CLOUDAPI_TOKEN}' \
-H 'Content-Type: application/json' \
-d '{"_type": "Device"}'
url ${CLOUD_ENDPOINT}/tok/generic/find \
'Authorization: ${CLOUDAPI_TOKEN}' \
'{_type: "Device"}'
Get
Get a data item from a database table.
Endpoint
POST /generic/get
Authorized User Role
user
Request Body
Field | Type | Required | Notes |
---|---|---|---|
_type | string | yes | Database item type. |
deviceId | string | Device ID owning the item. | |
* | any | Optional item attributes to filter the selected item. |
Response
The retrieved item.
Field | Type | Notes |
---|---|---|
* | any | Item attributes. |
curl -X POST ${CLOUD_ENDPOINT}/tok/generic/get \
-H 'Authorization: ${CLOUDAPI_TOKEN}' \
-H 'Content-Type: application/json' \
-d '{"_type": "Device", "deviceId": "DEV0123456"}'
url ${CLOUD_ENDPOINT}/tok/generic/get \
'Authorization: ${CLOUDAPI_TOKEN}' \
'{_type: "Device", deviceId: "DEV0123456"}'
Remove
Remove a data item.
Endpoint
POST /generic/remove
Authorized User Role
user
Request Body
Field | Type | Required | Notes |
---|---|---|---|
_type | string | yes | Database item type. |
deviceId | string | Device ID owning the item. | |
* | any | Other item attributes sufficient to identify the item. |
Update
Update a data item.
Endpoint
POST /generic/update
Authorized User Role
user
Request Body
Field | Type | Required | Notes |
---|---|---|---|
_type | string | yes | Database item type. |
deviceId | string | Device ID owning the item. | |
* | any | Other item attributes sufficient to identify the item. |
Response
The updated data item.
Field | Type | Notes |
---|---|---|
* | any | Item attributes. |