update method

Update an existing record

Implementation

Future<DocumentsModel?> update(DocumentsModel model) async {
  if (model.id == null) {
    throw ArgumentError("Primary key id cannot be null for update operation");
  }
  final queryBuilder = query.update(model.toJson())
      .eq('id', model.id!)
      .select()
      .maybeSingle();

  final response = await queryBuilder;
  if (response == null) return null;
  return fromJson(response);
}