Compare commits
2 commits
d2de8e961d
...
6fea1a4695
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fea1a4695 | |||
| cc6ac32324 |
2 changed files with 38 additions and 0 deletions
12
README.md
12
README.md
|
|
@ -27,3 +27,15 @@ $ tern new --migrations ./internal/store/pgstore/migrations create_messages_tabl
|
|||
|
||||
`tern.config` does not read `.env` file directly so a wrapper was created to be
|
||||
able to load environment variables.
|
||||
|
||||
### Installing sqlc
|
||||
|
||||
```bash
|
||||
$ go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
||||
```
|
||||
|
||||
### Generate sql types
|
||||
|
||||
```bash
|
||||
$ sqlc generate -f ./internal/store/pgstore/sqlc.yaml
|
||||
```
|
||||
|
|
|
|||
26
internal/store/pgstore/queries.sql.go
Normal file
26
internal/store/pgstore/queries.sql.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: queries.sql
|
||||
|
||||
package pgstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const getRoom = `-- name: GetRoom :one
|
||||
SELECT
|
||||
"id", "theme"
|
||||
FROM rooms
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetRoom(ctx context.Context, id uuid.UUID) (Room, error) {
|
||||
row := q.db.QueryRow(ctx, getRoom, id)
|
||||
var i Room
|
||||
err := row.Scan(&i.ID, &i.Theme)
|
||||
return i, err
|
||||
}
|
||||
Loading…
Reference in a new issue