// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: practices.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const CreatePractice = `-- name: CreatePractice :one INSERT INTO practices ( owner_type, owner_id, title, description, banner_image, persona, is_active ) VALUES ( $1, -- owner_type (LEVEL | MODULE) $2, -- owner_id $3, -- title $4, -- description $5, -- banner_image $6, -- persona $7 -- is_active ) RETURNING id, owner_type, owner_id, title, description, banner_image, persona, is_active ` type CreatePracticeParams struct { OwnerType string `json:"owner_type"` OwnerID int64 `json:"owner_id"` Title string `json:"title"` Description pgtype.Text `json:"description"` BannerImage pgtype.Text `json:"banner_image"` Persona pgtype.Text `json:"persona"` IsActive bool `json:"is_active"` } func (q *Queries) CreatePractice(ctx context.Context, arg CreatePracticeParams) (Practice, error) { row := q.db.QueryRow(ctx, CreatePractice, arg.OwnerType, arg.OwnerID, arg.Title, arg.Description, arg.BannerImage, arg.Persona, arg.IsActive, ) var i Practice err := row.Scan( &i.ID, &i.OwnerType, &i.OwnerID, &i.Title, &i.Description, &i.BannerImage, &i.Persona, &i.IsActive, ) return i, err } const DeactivatePractice = `-- name: DeactivatePractice :exec UPDATE practices SET is_active = FALSE WHERE id = $1 ` func (q *Queries) DeactivatePractice(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, DeactivatePractice, id) return err } const GetPracticeByID = `-- name: GetPracticeByID :one SELECT id, owner_type, owner_id, title, description, banner_image, persona, is_active FROM practices WHERE id = $1 ` func (q *Queries) GetPracticeByID(ctx context.Context, id int64) (Practice, error) { row := q.db.QueryRow(ctx, GetPracticeByID, id) var i Practice err := row.Scan( &i.ID, &i.OwnerType, &i.OwnerID, &i.Title, &i.Description, &i.BannerImage, &i.Persona, &i.IsActive, ) return i, err } const ListPracticesByOwner = `-- name: ListPracticesByOwner :many SELECT id, owner_type, owner_id, title, description, banner_image, persona, is_active FROM practices WHERE owner_type = $1 AND owner_id = $2 AND is_active = TRUE ORDER BY id ASC ` type ListPracticesByOwnerParams struct { OwnerType string `json:"owner_type"` OwnerID int64 `json:"owner_id"` } func (q *Queries) ListPracticesByOwner(ctx context.Context, arg ListPracticesByOwnerParams) ([]Practice, error) { rows, err := q.db.Query(ctx, ListPracticesByOwner, arg.OwnerType, arg.OwnerID) if err != nil { return nil, err } defer rows.Close() var items []Practice for rows.Next() { var i Practice if err := rows.Scan( &i.ID, &i.OwnerType, &i.OwnerID, &i.Title, &i.Description, &i.BannerImage, &i.Persona, &i.IsActive, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const UpdatePractice = `-- name: UpdatePractice :one UPDATE practices SET title = $2, description = $3, banner_image = $4, persona = $5, is_active = $6 WHERE id = $1 RETURNING id, owner_type, owner_id, title, description, banner_image, persona, is_active ` type UpdatePracticeParams struct { ID int64 `json:"id"` Title string `json:"title"` Description pgtype.Text `json:"description"` BannerImage pgtype.Text `json:"banner_image"` Persona pgtype.Text `json:"persona"` IsActive bool `json:"is_active"` } func (q *Queries) UpdatePractice(ctx context.Context, arg UpdatePracticeParams) (Practice, error) { row := q.db.QueryRow(ctx, UpdatePractice, arg.ID, arg.Title, arg.Description, arg.BannerImage, arg.Persona, arg.IsActive, ) var i Practice err := row.Scan( &i.ID, &i.OwnerType, &i.OwnerID, &i.Title, &i.Description, &i.BannerImage, &i.Persona, &i.IsActive, ) return i, err }