Answer the question
In order to leave comments, you need to log in
How to do join-conditions in Rest API?
Everything is fine when you need to search for a user in api by first or last name. But what to do if you need to find all users who have orders - it's not clear.
There is, of course, an option with a selection of all users and orders and applying the conditions, but I do not consider this.
There is a variant with a condition parameter of type countOrders > 0, and check this separately in the api implementation.
You can also add a separate method like getCustomerWithOrders().
How do you do things like this in api?
Answer the question
In order to leave comments, you need to log in
As an option denormalization of the data. Adds count_order to the user table, update counter when adding/removing an order. This will redistribute the load from select to insert and delete (no need to join in the select query, but insert will be a little slower due to the extra update query).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question