Open willdochnur opened 4 months ago
Could you share what your use case is for this?
If your RelationMap
is properly typed and you are working with relations statically, you should get a compile time error from TypeScript if you reference a relation that doesn't exist.
To detect and filter out non-existent relations at run-time would require this library to validate relations against the entity metadata. It doesn't look at the metadata at all currently, it just works with relation mapping objects in a generic way.
I would like to reuse fields
which includes simple datatypes and relations:
const fields = {
id: true,
name: true,
customer: {
id: true,
name: true
anotherRelation: {
id: true,
name: true
}
}
};
await ManagementDataSource.getRepository(ProjectEntity).find({
relations: projectRelationMap.toFindOptionsRelations(fields),
select: fields
});
toFindOptionsRelations
should filter out all simple data types and take all nested relations.
Result of toFindOptionsRelations
should be:
{ customer: { anotherRelation: true } }
It would be nice if
toFindOptionsRelations
would filter everything out what is not a relation.