the rest
This commit is contained in:
96
internal/db/services.sql.go
Normal file
96
internal/db/services.sql.go
Normal file
@@ -0,0 +1,96 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: services.sql
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createService = `-- name: CreateService :one
|
||||
INSERT INTO services (name, description, price_cents, created_at)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, name, description, price_cents, created_at
|
||||
`
|
||||
|
||||
type CreateServiceParams struct {
|
||||
Name string `json:"name"`
|
||||
Description sql.NullString `json:"description"`
|
||||
PriceCents int32 `json:"price_cents"`
|
||||
CreatedAt sql.NullTime `json:"created_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateService(ctx context.Context, arg CreateServiceParams) (Service, error) {
|
||||
row := q.db.QueryRowContext(ctx, createService,
|
||||
arg.Name,
|
||||
arg.Description,
|
||||
arg.PriceCents,
|
||||
arg.CreatedAt,
|
||||
)
|
||||
var i Service
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.PriceCents,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getService = `-- name: GetService :one
|
||||
SELECT id, name, description, price_cents, created_at
|
||||
FROM services
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetService(ctx context.Context, id int64) (Service, error) {
|
||||
row := q.db.QueryRowContext(ctx, getService, id)
|
||||
var i Service
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.PriceCents,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listServices = `-- name: ListServices :many
|
||||
SELECT id, name, description, price_cents, created_at
|
||||
FROM services
|
||||
ORDER BY id DESC
|
||||
`
|
||||
|
||||
func (q *Queries) ListServices(ctx context.Context) ([]Service, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listServices)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []Service{}
|
||||
for rows.Next() {
|
||||
var i Service
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.PriceCents,
|
||||
&i.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user