MENU

Fun & Interesting

SQLc is the perfect tool for those who don't like ORMs

Dreams of Code 119,148 4 months ago
Video Not Working? Fix It Now

Click this link https://sponsr.is/bootdev_dreamsofcode and use my code DREAMSOFCODE to get 25% off your first payment for boot.dev. That’s 25% off your first month or your first year, depending on the subscription you choose. When it comes to working with a database in Go, I often make use of the Repository Design Pattern, which wraps the queries into type safe functions. Whilst this is my preferred approach, it does take a lot of time as it's mostly tedious to do. Fortunately, there's a new tool out there called SQLc which solves this, and many other problems. This video is sponsored by boot.dev Video Links: - SQLc: https://sqlc.dev/ - Code: https://github.com/dreamsofcode-io/sqlc - Repository Design Pattern: https://medium.com/@pererikbergman/repository-design-pattern-e28c0f3e4a30 Gear Used: Keyboard: ZSA Voyager Mouse: https://amzn.to/3UbDaHM Camera: https://amzn.to/4eFPvvP Lens: https://amzn.to/3YmMR8v Microphone: https://amzn.to/4eFPvvP Video Interface: https://amzn.to/3zUjRvF Audio Interface: https://amzn.to/3U8Zd1s Join this channel to get access to perks: https://www.youtube.com/channel/UCWQaM7SpSECp9FELz-cHzuQ/join Join Discord: https://discord.com/invite/eMjRTvscyt Join Twitter: https://twitter.com/dreamsofcode_io 00:00:00 Intro 00:01:49 SQLc 00:04:02 Sponsor 00:05:43 Simple Example 00:07:22 Define Schema 00:08:14 Define Queries 00:09:03 Query Annotations 00:10:11 Code Gen Config 00:10:55 Installing SQLc 00:11:28 Generated Code 00:12:18 Integration 00:14:07 Insert Query 00:16:12 Returning * 00:17:49 Overrides 00:20:04 json tags 00:20:31 Embedded Structs 00:22:05 Prepared Statements 00:22:36 Transactions 00:26:25 Query Organization

Comment