ZCQL
ZCQL is Catalyst’s own query language that enables you to perform data creation, retrieval, and modification operations in the Data Store. It supports queries with built-in functions, SQL Join clauses, and other statements and conditions.
Execute a ZCQL Query
Flutter enables you to perform data retrieval operations using ZCQL. Before you execute a ZCQL query to fetch the required data set, you must construct the query to pass it to the getData() method. You can learn about the ZCQL syntax from the ZCQL help page.
You must pass an instance of ZCatalystSelectQuery to the getData() method, as shown in the code syntax of a ZCQL query execution below.
The <DATA_STORE_INSTANCE> used here is the instance defined in the Data Store Instance page.
copyZCatalystApp.getInstance().getDataStoreInstance().getData( ZCatalystSelectQuery selectQuery, void Function(List<Map<String, Map<String, Dynamic?>>>) onSuccess, void Function(ZCatalystException) onFailed )
Parameters:
- selectQuery: The instance of the type ZCatalystSelectQuery to be passed
You can create a selectQuery instance for ZCatalystSelectQuery for the statements supported by ZCQL, in the following way:
copyZCatalystSelectQuery.Builder() .select(columns: Set<Column>): ZCatalystSelectQuery.Builder .selectAll(): ZCatalystSelectQuery.Builder .where(column: String, comparator: ZCatalystUtil.Comparator, value: String): ZCatalystSelectQuery.Builder .from(tableName: String): ZCatalystSelectQuery.Builder .and(column: String, comparator: ZCatalystUtil.Comparator, value: String): ZCatalystSelectQuery.Builder .groupBy(columns: Set<Column>): ZCatalystSelectQuery.Builder .orderBy(columns: Set<Column>, sortOrder: ZCatalystUtil.SortOrder): ZCatalystSelectQuery.Builder .innerJoin(tableName: String): ZCatalystSelectQuery.Builder .leftJoin(tableName: String): ZCatalystSelectQuery.Builder .on(joinColumn1: String, comparator: ZCatalystUtil.Comparator, joinColumn2: String): ZCatalystSelectQuery.Builder .or(column: String, comparator: ZCatalystUtil.Comparator, value: String): ZCatalystSelectQuery.Builder .limit(offset: Int, value: Int?): ZCatalystSelectQuery.Builder .build(): ZCatalystSelectQuery
A sample code snippet of a ZCQL query execution is shown below:
copyZCQLColumn column1 = ZCQLColumn('Title'); ZCQLColumn column2 = ZCQLColumn('Category'); Set<ZCQLColumn> columns = Set(); columns.add(column1); columns.add(column2); //Selecting the columns to be fetched ZCatalystSelectQuery query = ZCatalystQueryBuilder() .select(columns) .from('Products') .where('Category', Comparator.EQUAL_TO, 'Electronics') .build(); //Defining the query with a WHERE condition ZCatalystApp.getInstance().getDataStoreInstance().getData(query, (APIResponse response, List<dynamic>? result) { //Passing the query instance to the getData() method print('Select Query Result :'); print(result); //Actions to be executed upon a sucessful execution of the query }, (ZCatalystException exception) { print('ZCQL Query has failed to execute : ${exception}'); //Actions to be executed upon failure });
Last Updated 2023-09-03 01:06:41 +0530 +0530
Yes
No
Send your feedback to us