Query which needs to change the state of the database #1190
Unanswered
andrew1555
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
So a question came up with how we would handle the scenario when a query would have to modify the database and how do this is a clean way.
So typically we have HTTP GET and POST methods, GET methods would call Queries and POST would call commands. This keeps it nice and clean, but we have some situations where on loading in the data we need to validate this and sometimes perform writes back to the database.
For example when we load in a shopping basket via the GetBasketQuery, we have to check the stock levels. Should stock fall below the threshold we would then delete this item from the customers basket.
Therefore is it OK to do this in the query? Or is there a neater way to achieve this.
Likewise is it OK for queries to fire events, like logging a user a performed a certain query (for reporting purposes)
Thanks
Andrew
Beta Was this translation helpful? Give feedback.
All reactions