This may be the option. But what I need is to add this as a field to a response for a usual query, which is still `GET /Books`. Because client does not need to have to use two different methods to get this information. Moreover, the number of this relations may be more than one. For example, you might want to display the number of related Authors as well.
The only way I see it can be done is to use remoteMethod hook and for each book in results set do a count of books. What I don't like about this approach is that it requires custom code, while this kind of functionality may be useful in other places. Also, I'm not sure how easy it will be to hide this derived field using filter query parameter, if the counts are not necessary. Unless you want to implement the logic of parsing filter query params in remoteMethod hook as well. That's why I'd like it to be configured rather than coded. I think that something like a scope for relation would be a good alternative. But instead of getting the full list I would need to get the count. Is it possible to achieve this somehow?
Thanks,
Alex.