How do you handle more complicated relationships with filters? #32
-
Hi Ben, I am working on a project that uses SQL and I landed on a design that's pretty similar to this project's, but one thing I am struggling with a bit is how to handle more complex filters using the
but it feels awkward to encode those in Go structs, even if I don't really need them to be general (ie, I probably will never need I'm curious if you have any suggestions for how to deal with this that still maintains the separation of the "service" layer from the SQL layer. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi Joe, I agree it feels a bit awkward but I haven't found a better way of doing it personally. You could build some kind of Ben |
Beta Was this translation helpful? Give feedback.
-
If you wanted the exciting conclusion to this, as I've done further development I've found that the number of ways I need to query and update are pretty limited and the generic route isn't especially worth the added complexity. So instead of:
I've defined specific methods:
which seem fine given my limited number of operations. |
Beta Was this translation helpful? Give feedback.
Hi Joe,
I agree it feels a bit awkward but I haven't found a better way of doing it personally. You could build some kind of
Expr
type that has EQ/LT/GT/etc but that sounds overly complicated for this kind of thing.Ben