I'm learning CQRS pattern as we going to use it on our new project. And I have few questions so far:
Example task: I'll have cron command to fetch information from different providers (different API's) and responsibility of this cron command is:
- fetch data from all provided;
- make additional API call's to get images and videos;
- process those videos and images (store to aws s3) and to uploads table in DB;
- fetch existing data from DB;
- transform new API data to system entities, update existing entities and delete nonexistent;
- persist DB. ;
CQRS related questions:
- Can I have few CQRS commands and queries inside of one system request? In the example above I need to get existing data from DB (query), persist data (command) and so on.
- what about the logic of fetching data from API's can I consider it as a CQRS query as its process of getting data or CQRS query it's the only process of getting data from internal storage, not from external API?
- What about the process of storing videos to s3 and storing information to uploads table, can I consider the process of storing assets to S3 as a CQRS command and this command will return data I need to store later to uploads? I do not want to store it immediately as upload entity is a part of aggregate to store main info where main info entity is the main aggregate entity. I know command should return nothing or entity ID but here it will return all data about stores assets
If all the questions from above are true, so I can make:
- query to fetch API data
- query to get existing data
- command to process images/videos
- command to insert/update/delete data
Don't judge me very strict, I'm in process of learning concepts of DDD and related patterns. And I just ask the questions what is not clear for me. Thank you very much