setRelation method
Future<int?>
setRelation(
- String parentObjectId,
- String relationColumnName, {
- List<
String> ? childrenObjectIds, - String? whereClause,
override
The API request has 2 options:
- Must explicitly specify child objects to set to the relation by referring to their identifiers.
- Child objects are referenced implicitly through the whereClause clause, which defines the condition for selecting the object.
At least 1 optional parameter must be defined. If 2 optional parameters are defined, 1 option is preferred. The API returns the number of objects the operation sets to the relations.
Implementation
@override
Future<int?> setRelation(String parentObjectId, String relationColumnName,
{List<String>? childrenObjectIds, String? whereClause}) async {
String methodName = '/data/$tableName/$parentObjectId/$relationColumnName';
List<String>? parameters;
if (childrenObjectIds?.isNotEmpty ?? false) {
parameters = childrenObjectIds;
} else if (whereClause?.isNotEmpty ?? false) {
methodName += '?where=$whereClause';
}
return await Invoker.post(methodName, parameters);
}