executeSumQuery method

Future<num?> executeSumQuery({
  1. required String field,
  2. required AGConnectCloudDBQuery query,
  3. required AGConnectCloudDBZoneQueryPolicy policy,
})

You can call this method to search for Cloud DB zone objects that meet the specified conditions and return the sum of the data record values of the designated fields.

Comply with the following rules when invoking this method:

  • This method is called to query the sum of the specified fields only when Cloud DB zone is opened. Otherwise, the query will fail.
  • The startAt(), startAfter(), endAt(), and endBefore() methods cannot be used as query conditions.
  • Supports the following data types:
    • int for Byte, Short, Integer, and Long.
    • double for Double, and Float.

Implementation

Future<num?> executeSumQuery({
  required String field,
  required AGConnectCloudDBQuery query,
  required AGConnectCloudDBZoneQueryPolicy policy,
}) async {
  if (field.isEmpty) {
    throw FormatException('Value of field cannot be an empty string.', field);
  }
  try {
    return await _methodChannel.invokeMethod<num?>(
      _MethodConstants.EXECUTE_SUM_QUERY,
      <String, dynamic>{
        _KeyConstants.ZONE_ID: _id,
        _KeyConstants.FIELD: field,
        _KeyConstants.QUERY: query.query,
        _KeyConstants.POLICY_INDEX: policy.index,
      },
    );
  } catch (e) {
    throw AGConnectCloudDBException._from(e);
  }
}