42 lines
926 B
Go
42 lines
926 B
Go
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
// versions:
|
||
|
// sqlc v1.20.0
|
||
|
// source: users.sql
|
||
|
|
||
|
package db
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
)
|
||
|
|
||
|
const createUser = `-- name: CreateUser :exec
|
||
|
INSERT INTO users (name) VALUES (?)
|
||
|
`
|
||
|
|
||
|
func (q *Queries) CreateUser(ctx context.Context, name string) error {
|
||
|
_, err := q.db.ExecContext(ctx, createUser, name)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
const getUserByID = `-- name: GetUserByID :one
|
||
|
SELECT id, name FROM users WHERE id = ?
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error) {
|
||
|
row := q.db.QueryRowContext(ctx, getUserByID, id)
|
||
|
var i User
|
||
|
err := row.Scan(&i.ID, &i.Name)
|
||
|
return i, err
|
||
|
}
|
||
|
|
||
|
const getUserByName = `-- name: GetUserByName :one
|
||
|
SELECT id, name FROM users WHERE name = ?
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetUserByName(ctx context.Context, name string) (User, error) {
|
||
|
row := q.db.QueryRowContext(ctx, getUserByName, name)
|
||
|
var i User
|
||
|
err := row.Scan(&i.ID, &i.Name)
|
||
|
return i, err
|
||
|
}
|