Skip to content

Querying Column Items

Querying column items is useful when you want to get the unique values of a specific column or just want to get all the values of a specific column. By using kala server we can leverage the power of querying column items includes

  • Query only unique values using distinct
  • Pagination to limit the result
  • Filtering data using CQL 2 Filter

Query parameter consist of this fields:

  • filter: (object) Optional, CQL 2 Filter to filter the data may include other column, for now only support textual CQL 2 filter maybe in unforseeable future we will support JSON CQL 2 Filter
  • page: (number) Optional, page number for pagination
  • perPage: (number) Optional, limit the result per page

The response will be

{
"data": [1,2,3]
"pagination": {
"page": 1,
"perPage": 10,
"total": 30
}
}

For the sake of quick writing, because of the limited time we have, so here we go the example directly.

Let’s say we have a PostGIS datastore called postgis_sample and a collection called city which has the following columns

  • name (string)
  • population (number)
  • area (number)
  • province (string)
  • geom (geometry)
POST /api/data/datastore/postgis_sample/collection/countries/columns/province/items?unique=false&page=1&perPage=5
Content-Type: application/json
{
"data": ["JATENG", "JATENG", "JAWA BARAT", "JAWA BARAT", "DKI JAKARTA"],
"pagination": {
"page": 1,
"perPage": 5,
"total": 100
}
}
POST /api/data/datastore/postgis_sample/collection/countries/columns/province/items?unique=true&page=1&perPage=5
Content-Type: application/json
{
"data": ["JATENG", "JAWA BARAT", "DKI JAKARTA", "BALI", "SUMATERA UTARA"],
"pagination": {
"page": 1,
"perPage": 5,
"total": 38
}
}
POST /api/data/datastore/postgis_sample/collection/countries/columns/province/items?unique=true&page=1&perPage=5&filter=province LIKE 'JA%'
Content-Type: application/json
{
"data": ["JATENG", "JAWA BARAT", "DKI JAKARTA", "JAMBI", "JAWA TIMUR"],
"pagination": {
"page": 1,
"perPage": 5,
"total": 5
}
}