Get Rows#

Query data from the table.

Endpoint#
 POST https://api.cloudplan.net/api/tables/get_rows

Request Parameters#

Possible request parameters#
{
    "table_id": "",
    "query": {},
    "limit": 0,
    "skip": 0,
    "projection": [],
    "sort_by": "",
    "sort_dir": 1,
    "pipeline": []
}

table_id | (string)

Id of the table to query.

query | (optional) (object)

A filter object for the datatable, see Query Filters below for options.

default: {}

limit | (optional) (integer)

Return no more than this number of rows.

default: 100 - this also the maximum

skip | (optional) (integer)

Skip this many rows. Together with limit this implements paging of the result.

default: 0

projection | (optional) (list of strings)

A list of columns (cx’s’) to include in the result.

Example: ['c0', 'c1'] returns only first two columns.

default: []

sort_by | (optional) (string)

Sort by this column cx. Default sorting is by order of insertion, oldest first.

default: ‘’

sort_dir | (optional) (integer)

Gives the direction of sorting. Possible values are:

  • 1 -> ascending

  • -1 -> descending

default: 1

pipeline | (optional) (list of pipeline stage objects)

A aggregation pipeline, used instead of the query parameter for complex data retrieval. If specified, the query parameter is ignored. See Aggregation Pipeline for more info.

Reply Parameters#

Reply#
{
    "row_docs": [
        {
            "row_id": "67516C89B37D58C1A96E887A64D5F458",
            "table_id": "67516C890DD0DCE7F2E39C4627E923F9",
            "c0": "Some Value"
        }
    ],
    "total_count": 1
}

row_docs | (list of objects)

A list of row objects. See Row Objects

total_count | (integer)

The total number of rows matched. Useful for paging through the result since the number of returned row documents is limited.

Examples#

Here are some examples for using get_rows. Assume we have the following table definition and stored rows. Some ids and paramters in the objects have been omitted for better readability.

The table object used in these examples#
{
    "table_id": "6960D3994737607552574B980961708E",
    "name": "example table"
    "col_settings": {
        "c0": {
            "name": "Column 0 Text",
            "display_type": "string"
        },
        "c1": {
            "name": "Column 1 Number",
            "display_type": "integer"
        },
        "c1": {
            "name": "Column 2 Number",
            "display_type": "integer"
        }
    }
}
The rows of the table.#
[
    { "c0": "Frank", "c1": 12, "c2": 101 },
    { "c0": "Niels", "c1": 34, "c2": 102 },
    { "c0": "Heye", "c1": 56, "c2": 103 },
    { "c0": "Richard", "c1": 78, "c2": 104 },
]

Minimal Example Request

This returns all rows of the table.

Example get_rows request with mandatory parameters only.#
{
    "table_id": "6960D3994737607552574B980961708E"
}
Reply for the minimal example#
{
    "row_docs": [
        { "c0": "Frank",   "c1": 12, "c2": 101},
        { "c0": "Niels",   "c1": 34, "c2": 102},
        { "c0": "Heye",    "c1": 56, "c2": 103},
        { "c0": "Richard", "c1": 78, "c2": 104},
    ]
    "total_count": 4
}

Extended Example Request

This retrieves rows from a table with a query and all possible paramters set except skip and limit. A pipeline is not used here, since it would override all other parameters.

Request with many used parameters#
{
    "table_id": "6960D3994737607552574B980961708E",
    "query": {"c1": {"$gt": 10, "$lt": 60}},
    "projection": ["c0", "c1"],
    "sort_by": "c1",
    "sort_dir": -1
}
Reply for the extended example#
{
    "row_docs": [
        { "c0": "Heye",    "c1": 56},
        { "c0": "Niels",   "c1": 34}
    ]
    "total_count": 4
}