// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: query.sql package db import ( "context" ) const createLocation = `-- name: CreateLocation :execlastid insert INTO locations (x,y,z,world, observable) VALUES (?,?,?,?,?) ` type CreateLocationParams struct { X int64 `db:"x" json:"x"` Y int64 `db:"y" json:"y"` Z int64 `db:"z" json:"z"` World int64 `db:"world" json:"world"` Observable int64 `db:"observable" json:"observable"` } // Location // // insert INTO locations (x,y,z,world, observable) VALUES (?,?,?,?,?) func (q *Queries) CreateLocation(ctx context.Context, arg CreateLocationParams) (int64, error) { result, err := q.db.ExecContext(ctx, createLocation, arg.X, arg.Y, arg.Z, arg.World, arg.Observable, ) if err != nil { return 0, err } return result.LastInsertId() } const createObservable = `-- name: CreateObservable :execlastid insert INTO observables (name, description) VALUES (?,?) ` type CreateObservableParams struct { Name string `db:"name" json:"name"` Description string `db:"description" json:"description"` } // Observable // // insert INTO observables (name, description) VALUES (?,?) func (q *Queries) CreateObservable(ctx context.Context, arg CreateObservableParams) (int64, error) { result, err := q.db.ExecContext(ctx, createObservable, arg.Name, arg.Description) if err != nil { return 0, err } return result.LastInsertId() } const destroyLocation = `-- name: DestroyLocation :exec delete from locations where id = ? ` // DestroyLocation // // delete from locations where id = ? func (q *Queries) DestroyLocation(ctx context.Context, id int64) error { _, err := q.db.ExecContext(ctx, destroyLocation, id) return err } const getExit = `-- name: GetExit :one select id, origin, dest from exits where id = ? LIMIT 1 ` // Exit // // select id, origin, dest from exits where id = ? LIMIT 1 func (q *Queries) GetExit(ctx context.Context, id int64) (Exit, error) { row := q.db.QueryRowContext(ctx, getExit, id) var i Exit err := row.Scan(&i.ID, &i.Origin, &i.Dest) return i, err } const getLocation = `-- name: GetLocation :one select id, x, y, z, world, observable from locations where id = ? LIMIT 1 ` // GetLocation // // select id, x, y, z, world, observable from locations where id = ? LIMIT 1 func (q *Queries) GetLocation(ctx context.Context, id int64) (Location, error) { row := q.db.QueryRowContext(ctx, getLocation, id) var i Location err := row.Scan( &i.ID, &i.X, &i.Y, &i.Z, &i.World, &i.Observable, ) return i, err } const getLocationExitsFrom = `-- name: GetLocationExitsFrom :many select id, origin, dest from exits where dest = ? ` // GetLocationExitsFrom // // select id, origin, dest from exits where dest = ? func (q *Queries) GetLocationExitsFrom(ctx context.Context, dest int64) ([]Exit, error) { rows, err := q.db.QueryContext(ctx, getLocationExitsFrom, dest) if err != nil { return nil, err } defer rows.Close() var items []Exit for rows.Next() { var i Exit if err := rows.Scan(&i.ID, &i.Origin, &i.Dest); 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 } const getLocationExitsTo = `-- name: GetLocationExitsTo :many select id, origin, dest from exits where origin = ? ` // GetLocationExitsTo // // select id, origin, dest from exits where origin = ? func (q *Queries) GetLocationExitsTo(ctx context.Context, origin int64) ([]Exit, error) { rows, err := q.db.QueryContext(ctx, getLocationExitsTo, origin) if err != nil { return nil, err } defer rows.Close() var items []Exit for rows.Next() { var i Exit if err := rows.Scan(&i.ID, &i.Origin, &i.Dest); 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 } const getObservable = `-- name: GetObservable :one select id, name, description from observables where id = ? LIMIT 1 ` // GetObservable // // select id, name, description from observables where id = ? LIMIT 1 func (q *Queries) GetObservable(ctx context.Context, id int64) (Observable, error) { row := q.db.QueryRowContext(ctx, getObservable, id) var i Observable err := row.Scan(&i.ID, &i.Name, &i.Description) return i, err } const updateLocation = `-- name: UpdateLocation :exec update locations SET x = ?, y = ?, z = ?, world = ?, observable = ? where id = ? ` type UpdateLocationParams struct { X int64 `db:"x" json:"x"` Y int64 `db:"y" json:"y"` Z int64 `db:"z" json:"z"` World int64 `db:"world" json:"world"` Observable int64 `db:"observable" json:"observable"` ID int64 `db:"id" json:"id"` } // UpdateLocation // // update locations SET // x = ?, // y = ?, // z = ?, // world = ?, // observable = ? // where id = ? func (q *Queries) UpdateLocation(ctx context.Context, arg UpdateLocationParams) error { _, err := q.db.ExecContext(ctx, updateLocation, arg.X, arg.Y, arg.Z, arg.World, arg.Observable, arg.ID, ) return err }