|
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
|
// versions:
|
|
|
|
|
// sqlc v1.30.0
|
|
|
|
|
// source: query.sql
|
|
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"database/sql"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const createLocation = `-- name: CreateLocation :exec
|
|
|
|
|
insert INTO LOCATIONS (x,y,z,world) VALUES (?,?,?,?)
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreateLocationParams struct {
|
|
|
|
|
X int64
|
|
|
|
|
Y int64
|
|
|
|
|
Z int64
|
|
|
|
|
World int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) CreateLocation(ctx context.Context, arg CreateLocationParams) error {
|
|
|
|
|
_, err := q.db.ExecContext(ctx, createLocation,
|
|
|
|
|
arg.X,
|
|
|
|
|
arg.Y,
|
|
|
|
|
arg.Z,
|
|
|
|
|
arg.World,
|
|
|
|
|
)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getLocation = `-- name: GetLocation :one
|
|
|
|
|
select id, x, y, z, world 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,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getLocationExitsFrom = `-- name: GetLocationExitsFrom :many
|
|
|
|
|
select id, "to", "from" from exits where from = ? LIMIT 1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) GetLocationExitsFrom(ctx context.Context, from sql.NullInt64) ([]Exit, error) {
|
|
|
|
|
rows, err := q.db.QueryContext(ctx, getLocationExitsFrom, from)
|
|
|
|
|
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.To, &i.From); 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, "to", "from" from exits where to = ? LIMIT 1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) GetLocationExitsTo(ctx context.Context, to sql.NullInt64) ([]Exit, error) {
|
|
|
|
|
rows, err := q.db.QueryContext(ctx, getLocationExitsTo, to)
|
|
|
|
|
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.To, &i.From); 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
|
|
|
|
|
}
|