Search

Catalyst Search enables data searching in the indexed columns of the tables in the Data Store. It allows you to perform powerful searches through volumes of data with a single search query.

Search Data in Tables

The search() method is used for searching data in the tables in a specific pattern. Before you execute a search operation, you must construct the search pattern to pass to the search() method, as shown in the code syntax below:

    
copy
ZCatalystApp.shared.search( searchOptions : ZCatalystSearchOptions, completion : @escaping( Result< [ String : Any ], ZCatalystError > ) -> Void )

Parameters:

  • searchOptions: The instance of the ZCatalystSearchOptions class to be passed to the search() method.
  • completion: If the call executes successfully, the completion block returns the data from the search results. Else, it returns an error.

You can create the instance for searchOptions in the following way:

    
copy
ZCatalystSearchOptions(searchText: String, searchColumns : [ TableColumns ])
.add(searchColumns : TableColumns)
.add(displayColumns : TableColumns)
.add(sortColumn : String, in table : String)
TableColumns( tableName : String )
TableColumns.add( column : String )

A sample code snippet of a search execution is shown below:

    
copy
var searchColumns = ZCatalystSearchOptions.TableColumns( tableName : "EmployeeDetails" ) //Replace this with your table name
searchColumns.add( column : "Age" )
//Replace this with your column name
var searchOptions = ZCatalystSearchOptions( searchText : "25", searchColumns : [ searchColumns ] )
//Replace this with your search text
var displayColumns = ZCatalystSearchOptions.TableColumns( tableName : "EmployeeDetails" ) //Replace this with your table name
displayColumns.add( column : "Age" )
//Replace this with your column name
searchOptions.add(displayColumns: displayColumns)
ZCatalystApp.shared.search( searchOptions : searchOptions) { ( result ) in
switch result{
case .success( let response ) :
print("Response : \( response )")
case .error( let error ) :
print( "Error occurred >>> \( error )" )
}
}

Last Updated 2023-09-03 01:06:41 +0530 +0530

ON THIS PAGE
ACCESS THIS PAGE