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
Endpoint
POST /generic/createAuthorized User Role
userRequest 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 manager account of the authenticated user. | |
| * | any | Item attributes to create. |
Query String Options
| Field | Type | Notes |
|---|---|---|
| exists | boolean | Set to true to require the item exists, otherwise set to null to perform an upsert. |
Response
The created item.
| Field | Type | Notes |
|---|---|---|
| _type | string | Database item type. |
| * | any | Item attributes. |
Get
Get a data item from a database table.
Endpoint
POST /generic/getAuthorized User Role
userRequest 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. |
Find
Find data items from a database table.
Endpoint
POST /generic/findAuthorized User Role
userRequest 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 | Notes |
|---|---|---|
| filter | string | Full text string to filter for. |
| next | object | Pagination token for the next page. |
| prev | object | Pagination token for the previous page. |
| limit | number | Number of items to retrieve. |
| index | string | Database index to use. |
| exists | boolean | Set to true to require the item exists, otherwise set to null to perform an upsert. |
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
An array of Item items.
| Field | Type | Notes |
|---|---|---|
| * | any | Item attributes. |
Remove
Remove a data item.
Endpoint
POST /generic/removeAuthorized User Role
userRequest 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/updateAuthorized User Role
userRequest 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. |
