3 ms·
The future isn't writing query handling code by hand or using ORM's. The future is reflection or code generation tools like https://sqlc.dev https://sqlc.dev W
by Xeoncross 3y ago
The future isn't writing query handling code by hand or using ORM's. The future is reflection or code generation tools like https://sqlc.dev https://sqlc.dev
Whether you use traditional queries or ORM's you still have to write all the model query code by hand in traditional systems. Projects like sqlc generate all the shapes/objects, validation, and everything else for you.
Simply define all your SQL queries in an easy to audit file and sqlc generates the entire model/store package for you. doesn't matter what language the generated code is in, as long as you can all read SQL you can understand the app. Then just plug the generated package into your HTTP API or GraphQL revolvers.
Try it out: https://play.sqlc.dev/ https://play.sqlc.dev/
This reminds me of the benefits that OpenAPI brings. A lot of teams are still writing client libraries by hand for each language instead of using an OpenAPI/Swagger spec.
- lfasdf__1 3y agoBeautiful. i was just looking for something like this for go yesterday.
- ChymeraXYZ 3y agoThis! Ever since I discovered sqlc it's my go to for any dB it supports. It's a joy to work with and does exactly what you expect it to, no strange magic.
- dizhn 3y agoStable for go code using postgres and mysql only at this time.