From 74ae6b78773aa338111cf1004f9235a7ad4ce661 Mon Sep 17 00:00:00 2001 From: Muyao CHEN Date: Sun, 20 Oct 2024 22:57:28 +0200 Subject: [PATCH] doc: add readme --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 8ed0927..a35632e 100644 --- a/README.md +++ b/README.md @@ -521,3 +521,28 @@ is on my future learning plan! _I found it quite interesting that simply with SQL, we can simulate the most business logic. It is a must-have competence for software design and development._ + +### 2024/10/20 + +I was thinking that I should write test for `sqlc` generated code. And then +I found out `gomock` and see how it is done in the project of +`techschoo/simplebank`. It's a great tutorial project. It makes me questioning +my own project's structure. It seems overwhelmed at least at the repo level. + +I don't actually use the sqlc generated object, instead I do a conversion to +my `Retrieved` objects. But with some advanced configuration we could make the +output of sqlc object directly usable. That will save a lot of code. + +The problem I saw here is the dependency on `sqlc/models`, and the model +designed there has no business logic. Everything is done in the handlers +and the handlers query directly the DB. + +More concretely, `sqlc` generates `RawJSON` for some fields that are embedded +structs. So I have to do the translation somewhere. + +So I will just stick to the plan and keep going with the predefined structure. + +I have to figure out how to use the generated mock files. + +The goals for the next week is to finish the basic operations for each level +and run some integration tests with `curl`.