fromJson static method

SupabaseQuery fromJson(
  1. Map<String, dynamic> json
)
override

Implementation

static SupabaseQuery fromJson(Map<String, dynamic> json) {
  if (json['supabase_query_type'] == SupabaseQueryTypes.insert.name) {
    return SupabaseQueryInsert(
      id: json['id'],
      table: json['table'],
      limit: json['limit'],
      offset: json['offset'],
      orderBy: json['order_by'],
      isCount: json['is_count'],
      filters: SupasetFilterEntity.fromJsonList(json['filters']),
      requestName: json['name'] as String,
      projectID: json['project_id'] as ProjectID,
      returnEntity: json['return_entity'] != null
          ? QueryReturnEntity.fromJson(json['return_entity'])
          : const QueryReturnEntity(
              modelID: null,
              returnType: ApiRequestReturnTypes.model,
            ),
      repositoryID: json['repository_id'] as ID?,
      single: json['single'] ?? false,
    );
  }
  if (json['supabase_query_type'] == SupabaseQueryTypes.update.name) {
    return SupabaseQueryUpdate(
      id: json['id'],
      table: json['table'],
      limit: json['limit'],
      offset: json['offset'],
      orderBy: json['order_by'],
      isCount: json['is_count'],
      filters: SupasetFilterEntity.fromJsonList(json['filters']),
      requestName: json['name'] as String,
      projectID: json['project_id'] as ProjectID,
      returnEntity: json['return_entity'] != null
          ? QueryReturnEntity.fromJson(json['return_entity'])
          : const QueryReturnEntity(
              modelID: null,
              returnType: ApiRequestReturnTypes.model,
            ),
      repositoryID: json['repository_id'] as ID?,
      single: json['single'] ?? false,
    );
  }
  if (json['supabase_query_type'] == SupabaseQueryTypes.delete.name) {
    return SupabaseQueryDelete(
      id: json['id'],
      table: json['table'],
      limit: json['limit'],
      offset: json['offset'],
      orderBy: json['order_by'],
      isCount: json['is_count'],
      filters: SupasetFilterEntity.fromJsonList(json['filters']),
      requestName: json['name'] as String,
      projectID: json['project_id'] as ProjectID,
      returnEntity: json['return_entity'] != null
          ? QueryReturnEntity.fromJson(json['return_entity'])
          : const QueryReturnEntity(
              modelID: null,
              returnType: ApiRequestReturnTypes.model,
            ),
      repositoryID: json['repository_id'] as ID?,
      single: json['single'] ?? false,
    );
  }
  if (json['supabase_query_type'] == SupabaseQueryTypes.select.name) {
    return SupabaseQuerySelect(
      id: json['id'],
      table: json['table'],
      select: json['select'],
      limit: json['limit'],
      offset: json['offset'],
      orderBy: json['order_by'],
      isCount: json['is_count'],
      filters: SupasetFilterEntity.fromJsonList(json['filters']),
      requestName: json['name'] as String? ?? '',
      projectID: json['project_id'] as ProjectID? ?? '',
      returnEntity: json['return_entity'] != null
          ? QueryReturnEntity.fromJson(json['return_entity'])
          : const QueryReturnEntity(
              modelID: null,
              returnType: ApiRequestReturnTypes.model,
            ),
      repositoryID: json['repository_id'] as ID?,
      single: json['single'] ?? false,
    );
  }
  throw Exception('Unknown action type');
}