So I have a method that receives an array of ids of a given entity in our database, I search in the db for those ids, and the ones that were not found I store them in DB, after that I return an array of those entities containing the ones that were already created and the new ones.
Since this entity has relations with a diversity of other entities, this logic is expected to be consumed by many command/query handlers, where should I put this logic?
- Create a service file that will be imported and called from each domain query/command handler?
- Create a command-handler doing this logic and call this command-handler from the other hanlders ( i think this is an anti-pattern right? )?