The Virtual data-base eases the access to the server side data-base from AntOS application. AntOS applications works on relational database at table level, it can freely create new table without any restriction.
The server side API MUST verify user permission before grant any access to the back-end relational database.
Table of content:
GET /VDB HTTP/1.1
Content-Type: application/json
API description:
{
"error": false,
"result": {
"description": "This api handle database operation",
"actions": {
"/delete": "Delete record(s) by condition or by id",
"/select": "Select records by a condition",
"/save": "Save a record to a table",
"/get": "Get all records or Get a record by id"
}
}
}
Save a record to a table, if the table does not exists, the server-side API should infer the table structure from the record, then create the table automatically. There is no API for table creation on the client side.
POST /VDB/save HTTP/1.1
Content-Type: application/json
{
"table": TABLE_NAME,
"data": DATA_RECORD
}
For example:
POST /VDB/save HTTP/1.1
Content-Type: application/json
{
"table": "user",
"data": {
"name": "John Doe",
"age": 30
}
}
The server side create the table if needed, then insert the data record to the table.
For example, with the previous request example, if the table user
does not exist, a table with the following structure should be created:
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
age INTEGER
);
The id
primary key is mandatory on all tables.
The server should responds with a result object that indicate whether the operation successes, for example:
{
"error": false,
"result": true
}
The request should be in the following formats:
POST /VDB/delete HTTP/1.1
Content-Type: application/json
{
"table": TABLE_NAME,
"id": RECORD_PRIMARY_KEY
}
or
POST /VDB/delete HTTP/1.1
Content-Type: application/json
{
"table": TABLE_NAME,
"cond": CONDITIONAL_OBJECT
}
The CONDITIONAL_OBJECT
is the object that represents a SQL condition.
More information on this object can be found at https://doc.iohub.dev/antos/api/classes/os.api.db.html#delete
The server should responds with a result object that indicate whether the operation successes, for example:
{
"error": false,
"result": true
}
Get the entire data in a table
The request should be in the following format:
POST /VDB/get HTTP/1.1
Content-Type: application/json
{
"table": TABLE_NAME
}
The table data in JSON format, for example:
{
"error": false,
"result": [
{
"name": "John Doe",
"age": 36
},
...
]
}
Select data records using a custom conditional object.
The request should be in the following formats:
POST /VDB/delete HTTP/1.1
Content-Type: application/json
{
"table": TABLE_NAME,
"cond": CONDITIONAL_OBJECT
}
The CONDITIONAL_OBJECT
is the object that represents a SQL condition.
More information on this object can be found at https://doc.iohub.dev/antos/api/classes/os.api.db.html#find
The selected records in JSON format, for example:
{
"error": false,
"result": [
{
"name": "John Doe",
"age": 36
},
...
]
}
Comments
The comment editor supports Markdown syntax. Your email is necessary to notify you of further updates on the discussion. It will be hidden from the public.