Updated Developers Guide (markdown)
parent
15be3a5214
commit
23993d2a7c
@ -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.
|
||||
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/).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user