findRelationByParent method

Future<List?> findRelationByParent({
  1. required List<ColumnRelation> relations,
  2. required List<String> dataIds,
  3. Database? database,
  4. String? orderParameters,
})

Implementation

Future<List?> findRelationByParent(
    {required List<ColumnRelation> relations,
    required List<String> dataIds,
    Database? database,
    String? orderParameters}) async {
  return Future.wait((relations).map((relation) async {
    final filters = [
      QueryFilter(
          attribute: relation.referencedColumn as String,
          condition: QueryCondition.In,
          value: dataIds)
    ];

    final String? whereParameters = QueryFilter.getWhereParameters(
        relation.referencedEntityColumns as List<Column>, filters);

    final Database db = database != null ? database : this.database;

    final newItem = await findWhereInRelation(
        database: db,
        entity: relation.referencedEntity as Entity,
        columns: relation.referencedEntityColumns as List<Column>,
        whereParameters: whereParameters,
        orderParameters: orderParameters);

    return {
      "relation": relation.attributeName,
      "referencedColumn": relation.referencedColumn,
      "data": newItem
    };
  }));
}