putting db stuff aside for a bit

main
Nick Dumas 2 weeks ago
parent c069782f32
commit 9781fb6736

@ -9,30 +9,30 @@ import (
)
type Exit struct {
ID int64
To sql.NullInt64
From sql.NullInt64
ID int64 `db:"id" json:"id"`
To sql.NullInt64 `db:"to" json:"to"`
From sql.NullInt64 `db:"from" json:"from"`
}
type Inventory struct {
ID int64
ID int64 `db:"id" json:"id"`
}
type Location struct {
ID int64
X int64
Y int64
Z int64
World int64
ID int64 `db:"id" json:"id"`
X int64 `db:"x" json:"x"`
Y int64 `db:"y" json:"y"`
Z int64 `db:"z" json:"z"`
World int64 `db:"world" json:"world"`
}
type Observable struct {
ID int64
Name string
Description string
ID int64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
}
type Pool struct {
ID int64
Type int64
ID int64 `db:"id" json:"id"`
Type int64 `db:"type" json:"type"`
}

@ -0,0 +1,31 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
package db
import (
"context"
"database/sql"
)
type Querier interface {
//CreateLocation
//
// insert INTO LOCATIONS (x,y,z,world) VALUES (?,?,?,?)
CreateLocation(ctx context.Context, arg CreateLocationParams) error
//GetLocation
//
// select id, x, y, z, world from locations where id = ? LIMIT 1
GetLocation(ctx context.Context, id int64) (Location, error)
//GetLocationExitsFrom
//
// select id, "to", "from" from exits where from = ? LIMIT 1
GetLocationExitsFrom(ctx context.Context, from sql.NullInt64) ([]Exit, error)
//GetLocationExitsTo
//
// select id, "to", "from" from exits where to = ? LIMIT 1
GetLocationExitsTo(ctx context.Context, to sql.NullInt64) ([]Exit, error)
}
var _ Querier = (*Queries)(nil)

@ -15,12 +15,15 @@ insert INTO LOCATIONS (x,y,z,world) VALUES (?,?,?,?)
`
type CreateLocationParams struct {
X int64
Y int64
Z int64
World int64
X int64 `db:"x" json:"x"`
Y int64 `db:"y" json:"y"`
Z int64 `db:"z" json:"z"`
World int64 `db:"world" json:"world"`
}
// CreateLocation
//
// insert INTO LOCATIONS (x,y,z,world) VALUES (?,?,?,?)
func (q *Queries) CreateLocation(ctx context.Context, arg CreateLocationParams) error {
_, err := q.db.ExecContext(ctx, createLocation,
arg.X,
@ -35,6 +38,9 @@ const getLocation = `-- name: GetLocation :one
select id, x, y, z, world from locations where id = ? LIMIT 1
`
// GetLocation
//
// 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
@ -52,6 +58,9 @@ const getLocationExitsFrom = `-- name: GetLocationExitsFrom :many
select id, "to", "from" from exits where from = ? LIMIT 1
`
// GetLocationExitsFrom
//
// 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 {
@ -79,6 +88,9 @@ const getLocationExitsTo = `-- name: GetLocationExitsTo :many
select id, "to", "from" from exits where to = ? LIMIT 1
`
// GetLocationExitsTo
//
// 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 {

@ -6,5 +6,8 @@ sql:
gen:
go:
emit_db_tags: true
emit_interface: true
emit_json_tags: true
emit_sql_as_comment: true
package: "db"
out: "db"

Loading…
Cancel
Save