Q: nestjsx/crud: How do define an alias for a filter field I have a nested typeorm OneToOne field in my model, call it Entity.related_entity. It's exposed to the API through the use of Nest/Crud endpoint.
I want to use the CRUD filter to filter on the related_entity fields, but currently it's only possible via ?filter=related_entity.some_field||$eq||10. How to make it so that it's possible to filter like this ?filter=some_field||$eq||10?

A: I do not think there is a way to register an alias for a filter. Assuming you are using the @Crud decorator on your controller, I think your best option would be the filter attribute of the query option (documented here). It allows you to register a function to transform your query search condition. In your case, you could have something like the following. Note that I have not tested that code and it might not work "as is", it is simply meant to give an idea of what the solution could look like.
function findAndReplaceAliases(search: SCondition) {
  search.$and.map((filter) =>
    filter.keys().contains('some_field')
      ? { 'related_entity.some_field': filter['some_field'] }
      : filter
  );
}

@Crud({
  query: {
    filter: findAndReplaceAliases
  }
})
@Controller()
SomeController {}

