rowId method

String rowId(
  1. dynamic row,
  2. bool isCreation
)

Implementation

String rowId(dynamic row, bool isCreation) {
  if (gceRowIdDebug) {
    logDebug(
      'rowId | editorConfig[primaryKeyName]: ${editorConfig['primaryKeyName']} | row: ${row.toString()}',
    );
  }

  String response = "";
  if (row is String) {
    response = row;
  } else if (row is Map<String, dynamic>) {
    response = getId(
      row.containsKey('_id') && getId(row['_id']).isNotEmpty
          ? row['_id']
          : row[editorConfig['primaryKeyName']],
    );
  } else {
    if (gceRowIdDebug) {
      logDebug("rowId | Unexpected row type: ${row.runtimeType}");
    }
    response = "";
  }

  if (response.isEmpty) {
    response = isCreation ? getHash(canonicalRow(row)) : "";
  }

  if (gceRowIdDebug) {
    logDebug('rowId | isCreation: $isCreation | response: $response');
  }
  return response;
}