From 23993d2a7c5c79f08f85c1abcf842734182746ed Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Sat, 10 Oct 2020 18:20:38 -0500 Subject: [PATCH] Updated Developers Guide (markdown) --- Developers-Guide.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Developers-Guide.md b/Developers-Guide.md index 597a887..3f3602e 100644 --- a/Developers-Guide.md +++ b/Developers-Guide.md @@ -88,4 +88,28 @@ All primary models live in `_models.gql` The root Query and Mutation objects live in `_root.gql` The rest of the files contain domain specific declarations. For instance the Mutations -for interacting with tasks is in the `task.gql` file. \ No newline at end of file +for interacting with tasks is in the `task.gql` file. + + +### Database Access + +Taskcafe uses `sqlc` (with `sqlx` for things that `sqlc` can not handle which hasn't been much so far) to handle database interactions. + +`internal/db` exports a `New` method that takes in a `sqlx.DB` connection and returns a `Repository`. + +The `Repository` contains all the methods generated by `sqlc` from the `internal/db/query` SQL files. + +If you have the below query in one of the SQL files: +``` sql +-- name: GetProjects :many +SELECT * FROM project; +``` + +Then the method can be accessed from the `Repository` like so: + +``` +projects, err := repository.GetProjects(ctx) +``` + +For more info on the `sqlc` query file format, take at look at [its documentation](https://sqlc.dev/). +