2025-01-21 18:24:14 +00:00
|
|
|
// 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"
|
|
|
|
|
)
|
|
|
|
|
|
2025-01-29 16:26:11 +00:00
|
|
|
const addClientCanSync = `-- name: AddClientCanSync :exec
|
|
|
|
|
INSERT INTO clientCanSync (canSync, clientId) VALUES ($1, $2)
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type AddClientCanSyncParams struct {
|
|
|
|
|
Cansync bool `db:"cansync"`
|
|
|
|
|
Clientid pgtype.UUID `db:"clientid"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AddClientCanSync
|
|
|
|
|
//
|
|
|
|
|
// INSERT INTO clientCanSync (canSync, clientId) VALUES ($1, $2)
|
|
|
|
|
func (q *Queries) AddClientCanSync(ctx context.Context, arg *AddClientCanSyncParams) error {
|
|
|
|
|
_, err := q.db.Exec(ctx, addClientCanSync, arg.Cansync, arg.Clientid)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
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
|
2025-02-20 19:02:44 +00:00
|
|
|
SELECT c.id, c.name, cs.canSync
|
2025-01-29 16:26:11 +00:00
|
|
|
FROM clients as c
|
2025-02-20 19:02:44 +00:00
|
|
|
JOIN currentClientCanSync as cs on cs.clientId = c.id
|
2025-01-29 16:26:11 +00:00
|
|
|
WHERE c.id = $1
|
2025-01-21 18:24:14 +00:00
|
|
|
`
|
|
|
|
|
|
2025-01-29 16:26:11 +00:00
|
|
|
type GetClientRow struct {
|
|
|
|
|
ID pgtype.UUID `db:"id"`
|
|
|
|
|
Name string `db:"name"`
|
|
|
|
|
Cansync bool `db:"cansync"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
// GetClient
|
|
|
|
|
//
|
2025-02-20 19:02:44 +00:00
|
|
|
// SELECT c.id, c.name, cs.canSync
|
2025-01-29 16:26:11 +00:00
|
|
|
// FROM clients as c
|
2025-02-20 19:02:44 +00:00
|
|
|
// JOIN currentClientCanSync as cs on cs.clientId = c.id
|
2025-01-29 16:26:11 +00:00
|
|
|
// WHERE c.id = $1
|
2025-02-20 19:02:44 +00:00
|
|
|
func (q *Queries) GetClient(ctx context.Context, id pgtype.UUID) (*GetClientRow, error) {
|
|
|
|
|
row := q.db.QueryRow(ctx, getClient, id)
|
2025-01-29 16:26:11 +00:00
|
|
|
var i GetClientRow
|
2025-01-21 18:24:14 +00:00
|
|
|
err := row.Scan(&i.ID, &i.Name, &i.Cansync)
|
|
|
|
|
return &i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const updateClient = `-- name: UpdateClient :exec
|
2025-01-29 16:26:11 +00:00
|
|
|
UPDATE clients SET name = $1 WHERE id = $2
|
2025-01-21 18:24:14 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type UpdateClientParams struct {
|
2025-01-29 16:26:11 +00:00
|
|
|
Name string `db:"name"`
|
|
|
|
|
ID pgtype.UUID `db:"id"`
|
2025-01-21 18:24:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateClient
|
|
|
|
|
//
|
2025-01-29 16:26:11 +00:00
|
|
|
// UPDATE clients SET name = $1 WHERE id = $2
|
2025-01-21 18:24:14 +00:00
|
|
|
func (q *Queries) UpdateClient(ctx context.Context, arg *UpdateClientParams) error {
|
2025-01-29 16:26:11 +00:00
|
|
|
_, err := q.db.Exec(ctx, updateClient, arg.Name, arg.ID)
|
2025-01-21 18:24:14 +00:00
|
|
|
return err
|
|
|
|
|
}
|