findByTo method

Future<List<EntityRelation>> findByTo(
  1. EntityId toId, {
  2. String? relationType,
  3. RelationTypeGroup? relationTypeGroup,
  4. RequestConfig? requestConfig,
})

Implementation

Future<List<EntityRelation>> findByTo(EntityId toId,
    {String? relationType,
    RelationTypeGroup? relationTypeGroup,
    RequestConfig? requestConfig}) async {
  var queryParameters = {
    'toId': toId.id,
    'toType': toId.entityType.toShortString()
  };
  if (relationType != null) {
    queryParameters['relationType'] = relationType;
  }
  if (relationTypeGroup != null) {
    queryParameters['relationTypeGroup'] = relationTypeGroup.toShortString();
  }
  var response = await _tbClient.get<List<dynamic>>('/api/relations',
      queryParameters: queryParameters,
      options: defaultHttpOptionsFromConfig(requestConfig));
  return response.data!.map((e) => EntityRelation.fromJson(e)).toList();
}