CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL, bio text
);
-- name: GetAuthor :one
SELECT * FROM authors WHERE id = $1 LIMIT 1;package db
import (
"context"
"database/sql"
)
type Author struct {
ID int64
Name string
Bio sql.NullString
}
const getAuthor = `-- name: GetAuthor :one
SELECT id, name, bio FROM authors
WHERE id = $1 LIMIT 1
`
type Queries struct {
db *sql.DB
}
func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) {
row := q.db.QueryRowContext(ctx, getAuthor, id)
var i Author
err := row.Scan(&i.ID, &i.Name, &i.Bio)
return i, err
}> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
Hoping to use it in my next project.