Get Rows
Get a Specific Row
You can retrieve a single specific row from a Data Store table of the given instance using the getRow() method. This is done by passing the unique ROWID of the row as the argument to this method, as shown in the code syntax below.
The <TABLE_INSTANCE> used in the code below is the instance defined in the Table Instance page .
copy
<TABLE_INSTANCE>.getRow(id : Int64, completion: @escaping (Result<ZCatalystRow, ZCatalystError>) -> Void)
Parameters:
- id: The unique ROWID of the particular row that needs to be retrieved
- completion: If the operation is successful, the completion block will return the details of the row. Else, it will return an error.
A sample code snippet is shown below:
copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845){( result ) in
// Replace this with your Table ID and ROW ID here
switch result{
case .success ( let row) :
print(row.id)
case .error( let error ) :
print( "Error occurred >>> \( error )" )
}
}
Get all Rows
You can retrieve all the rows of a table of the given instance, using the getRows() method, as shown in the code syntax below. If the operation is successful, this method will return all the rows of the table without any filters or conditions.
The <TABLE_INSTANCE> used in the code below is the instance defined in the Table Instance page .
copy
<TABLE_INSTANCE>.getRows(completion: @escaping (Result<[ZCatalystRow], ZCatalystError>) -> Void)
Parameters:
- completion: If the operation is successful, the completion block will return the details of all the rows. Else, it will return an error.
A sample code snippet is shown below:
copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance ( name : "EmployeeDetails").getRows{ ( result ) in
//Replace this with your table name
switch result{
case .success ( let rows) :
for row in rows{
print(row.id)
}
case .error( let error ) :
print( "Error occurred >>> \( error )" )
}
}
Yes
No
Send your feedback to us