Querying Column Items
Preface
Section titled “Preface”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
Request Structure
Section titled “Request Structure”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
Response structure
Section titled “Response structure”The response will be
{ "data": [1,2,3] "pagination": { "page": 1, "perPage": 10, "total": 30 }}Example
Section titled “Example”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)
Simple
Section titled “Simple”POST /api/data/datastore/postgis_sample/collection/countries/columns/province/items?unique=false&page=1&perPage=5Content-Type: application/json
{ "data": ["JATENG", "JATENG", "JAWA BARAT", "JAWA BARAT", "DKI JAKARTA"], "pagination": { "page": 1, "perPage": 5, "total": 100 }}Unique
Section titled “Unique”POST /api/data/datastore/postgis_sample/collection/countries/columns/province/items?unique=true&page=1&perPage=5Content-Type: application/json
{ "data": ["JATENG", "JAWA BARAT", "DKI JAKARTA", "BALI", "SUMATERA UTARA"], "pagination": { "page": 1, "perPage": 5, "total": 38 }}Unique + Filter
Section titled “Unique + Filter”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 }}