How to handle partial updates of domain objects #86
Unanswered
aloisbarreras
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
Uh oh!
There was an error while loading. Please reload this page.
HI @benbjohnson thanks for the great tutorials and code examples. I have a question about how you would handle an API route that can do partial updates. It's a fairly common pattern you see that only the fields specified in the body of the request are updated and any fields not specified will be unchanged.
I currently handle this using an
Optionaltype like so:then for example we could modify the
UserUpdatestruct from this repo to look like this:and in the
sqlitepackage when constructing the query, you can do (pseudocode):This seems like kind of a gray area where it's not quite related to the domain and business logic, and I feel like it could be argued that it's leaking implementation details into the domain. I don't want to be too dogmatic about it, so I'll probably continue with this pattern, but I wanted to check if there was a different way of doing this that I hadn't thought of and how you've handled something like this in your experience.
Thanks!
All reactions