04d8eaf52c
Client Entity * repolevel * servicefunctions * openapiclientget * openapiupdate * client * vendor
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: client.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createClient = `-- name: CreateClient :one
|
|
INSERT INTO clients (name) VALUES ($1) RETURNING id
|
|
`
|
|
|
|
// CreateClient
|
|
//
|
|
// INSERT INTO clients (name) VALUES ($1) RETURNING id
|
|
func (q *Queries) CreateClient(ctx context.Context, name string) (pgtype.UUID, error) {
|
|
row := q.db.QueryRow(ctx, createClient, name)
|
|
var id pgtype.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getClient = `-- name: GetClient :one
|
|
SELECT id, name, canSync FROM clients WHERE id = $1
|
|
`
|
|
|
|
// GetClient
|
|
//
|
|
// SELECT id, name, canSync FROM clients WHERE id = $1
|
|
func (q *Queries) GetClient(ctx context.Context, id pgtype.UUID) (*Client, error) {
|
|
row := q.db.QueryRow(ctx, getClient, id)
|
|
var i Client
|
|
err := row.Scan(&i.ID, &i.Name, &i.Cansync)
|
|
return &i, err
|
|
}
|
|
|
|
const updateClient = `-- name: UpdateClient :exec
|
|
UPDATE clients SET name = $1, canSync = $2 WHERE id = $3
|
|
`
|
|
|
|
type UpdateClientParams struct {
|
|
Name string `db:"name"`
|
|
Cansync bool `db:"cansync"`
|
|
ID pgtype.UUID `db:"id"`
|
|
}
|
|
|
|
// UpdateClient
|
|
//
|
|
// UPDATE clients SET name = $1, canSync = $2 WHERE id = $3
|
|
func (q *Queries) UpdateClient(ctx context.Context, arg *UpdateClientParams) error {
|
|
_, err := q.db.Exec(ctx, updateClient, arg.Name, arg.Cansync, arg.ID)
|
|
return err
|
|
}
|