* started schema * db schemas beginning * first db schema gen * added sqlc generation with go generate and sqlite driver * i think these dependencies are needed * added IF NOT EXISTS to create and CRUD for each table * fixed missing columns * added missing field * fixed code generation with sqlc
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: recordings.sql
|
|
|
|
package sqlcgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createRecording = `-- name: CreateRecording :one
|
|
INSERT INTO recordings (name) VALUES (?)
|
|
RETURNING id, name, artist_credit_id
|
|
`
|
|
|
|
func (q *Queries) CreateRecording(ctx context.Context, name string) (Recording, error) {
|
|
row := q.db.QueryRowContext(ctx, createRecording, name)
|
|
var i Recording
|
|
err := row.Scan(&i.ID, &i.Name, &i.ArtistCreditID)
|
|
return i, err
|
|
}
|
|
|
|
const deleteRecording = `-- name: DeleteRecording :exec
|
|
DELETE FROM recordings
|
|
WHERE id =?
|
|
`
|
|
|
|
func (q *Queries) DeleteRecording(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteRecording, id)
|
|
return err
|
|
}
|
|
|
|
const getRecording = `-- name: GetRecording :one
|
|
SELECT id, name, artist_credit_id FROM recordings
|
|
WHERE id = ? LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetRecording(ctx context.Context, id int64) (Recording, error) {
|
|
row := q.db.QueryRowContext(ctx, getRecording, id)
|
|
var i Recording
|
|
err := row.Scan(&i.ID, &i.Name, &i.ArtistCreditID)
|
|
return i, err
|
|
}
|
|
|
|
const updateRecording = `-- name: UpdateRecording :exec
|
|
UPDATE recordings
|
|
SET name = ?
|
|
WHERE id =?
|
|
`
|
|
|
|
type UpdateRecordingParams struct {
|
|
Name string
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateRecording(ctx context.Context, arg UpdateRecordingParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateRecording, arg.Name, arg.ID)
|
|
return err
|
|
}
|