// 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 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 } 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 c.id, c.name, coalesce(cs.canSync, false) as canSync FROM clients as c LEFT JOIN ( SELECT clientId, canSync FROM clientCanSync WHERE clientId = $1 ORDER BY addedAt DESC LIMIT 1 ) as cs on cs.clientId = c.id WHERE c.id = $1 ` type GetClientRow struct { ID pgtype.UUID `db:"id"` Name string `db:"name"` Cansync bool `db:"cansync"` } // GetClient // // SELECT c.id, c.name, coalesce(cs.canSync, false) as canSync // FROM clients as c // LEFT JOIN ( // SELECT clientId, canSync // FROM clientCanSync // WHERE clientId = $1 // ORDER BY addedAt DESC // LIMIT 1 // ) as cs on cs.clientId = c.id // WHERE c.id = $1 func (q *Queries) GetClient(ctx context.Context, clientid pgtype.UUID) (*GetClientRow, error) { row := q.db.QueryRow(ctx, getClient, clientid) var i GetClientRow err := row.Scan(&i.ID, &i.Name, &i.Cansync) return &i, err } const updateClient = `-- name: UpdateClient :exec UPDATE clients SET name = $1 WHERE id = $2 ` type UpdateClientParams struct { Name string `db:"name"` ID pgtype.UUID `db:"id"` } // UpdateClient // // UPDATE clients SET name = $1 WHERE id = $2 func (q *Queries) UpdateClient(ctx context.Context, arg *UpdateClientParams) error { _, err := q.db.Exec(ctx, updateClient, arg.Name, arg.ID) return err }