Get Rows

Query data from the table.

Request

POST https://uni.cloudplan.biz/api/tables/get_rows

{
    "table_id": "..."      //(string) id of the table
    "query": {...}         //(dict) query, see examples below
    "limit": 0             //(int, optional) default 1 limit output to a number of rows
    "skip": 0              //(int, optional) skip this many rows from the c0_too_many_ops
    "projection": ["c0", "c1", ...]   //(list, optional) only return these column values
    "sort_by": ""          //(string, optional) list by one of the column keys (c0...c5)
    "sort_dir": -1/1       //(int, optional) sort direction, as in mongodb 1 or -1
}

Reply

{
    "result": true/false,
    "reason": any error code (on failure)
    "row_docs": [...]
    "total_count": 1234
}

Query Operators:

$gt: greater than operator (note: string values will never match)
$gte: greater than equal (note: string values will never match)
$lt: less than operator (note: string values will never match)
$lte: less than equal (note: string values will never match)
$in: match any element in an array (can be numbers or strings)

Example 0

REQUEST:
{
    "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
    "limit": 100,
    "query":{"c0": 2}
}

REPLY:
{
    "result": true,
    "row_docs": [
        {
            "row": 2,
            "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
            "c0": 2,
            "c1": 1
        }
    ] ,
    "total_count": 23
}

Note: this is the most simple query possible, an exact macht for the value of column 0 (c0).
Note: if you want to query column values you always use the column names "c0", "c1", ....

Example 1

REQUEST:
{
    "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
    "limit": 100,
    "query":{"c0": {"$gte": 1, "$lte": 4}}
}

REPLY:
{
    "result": true,
    "row_docs": [
        {
            "row": 2,
            "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
            "c0": 2,
            "c1": 1
        }
    ],
    "total_count": 1
}

Note: the query wants the fist column value (c0) to be between 1 and 4 (inclusive)
Note: since number comparison operators are used, any rows where c0 contains a string will not be matched

Example 2

REQUEST
{
    "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
    "limit": 100,
    "query":{"c0": {"$in": [1,2,3,"cake"]}}
}

REPLY:
{
    "result": true,
    "row_docs": [
        {
            "row": 2,
            "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
            "c0": 2,
            "c1": 1
        },
        {
            "row": 4,
            "table_id": "5FB3A0FC19C59421F28DE0E80F79170A",
            "c0": "cake"
        }
    ],
    "total_count": 2
}

Note: the array of the $in operator may only contain primitive types float/int/string
Note: the $in operator can handle numbers as well as strings