deleteRelation method

  1. @override
Future<int?> deleteRelation(
  1. String parentObjectId,
  2. String relationColumnName, {
  3. List<String>? childrenObjectIds,
  4. String? whereClause,
})
override

The API request has 2 options:

  1. Removes specific objects from a relationship by ID with their parent..
  2. Deletes objects from a relationship with their parent. The objects are identified implicitly through a whereClause condition.

At least 1 optional parameter must be defined. If 2 optional parameters are defined, 1 option is preferred. The API returns the number of child objects removed from the relationship.

Implementation

@override
Future<int?> deleteRelation(String parentObjectId, String relationColumnName,
    {List<String>? childrenObjectIds, String? whereClause}) async {
  String methodName = '/data/$tableName/$parentObjectId/$relationColumnName';
  List? parameters;

  if (childrenObjectIds?.isNotEmpty ?? false) {
    parameters = childrenObjectIds;
  } else if (whereClause?.isNotEmpty ?? false) {
    methodName += '?where=$whereClause';
  }

  return await Invoker.delete(methodName, args: parameters);
}