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 { type Exit struct {
ID int64 ID int64 `db:"id" json:"id"`
To sql.NullInt64 To sql.NullInt64 `db:"to" json:"to"`
From sql.NullInt64 From sql.NullInt64 `db:"from" json:"from"`
} }
type Inventory struct { type Inventory struct {
ID int64 ID int64 `db:"id" json:"id"`
} }
type Location struct { type Location struct {
ID int64 ID int64 `db:"id" json:"id"`
X int64 X int64 `db:"x" json:"x"`
Y int64 Y int64 `db:"y" json:"y"`
Z int64 Z int64 `db:"z" json:"z"`
World int64 World int64 `db:"world" json:"world"`
} }
type Observable struct { type Observable struct {
ID int64 ID int64 `db:"id" json:"id"`
Name string Name string `db:"name" json:"name"`
Description string Description string `db:"description" json:"description"`
} }
type Pool struct { type Pool struct {
ID int64 ID int64 `db:"id" json:"id"`
Type int64 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 { type CreateLocationParams struct {
X int64 X int64 `db:"x" json:"x"`
Y int64 Y int64 `db:"y" json:"y"`
Z int64 Z int64 `db:"z" json:"z"`
World int64 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 { func (q *Queries) CreateLocation(ctx context.Context, arg CreateLocationParams) error {
_, err := q.db.ExecContext(ctx, createLocation, _, err := q.db.ExecContext(ctx, createLocation,
arg.X, arg.X,
@ -35,6 +38,9 @@ const getLocation = `-- name: GetLocation :one
select id, x, y, z, world from locations where id = ? LIMIT 1 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) { func (q *Queries) GetLocation(ctx context.Context, id int64) (Location, error) {
row := q.db.QueryRowContext(ctx, getLocation, id) row := q.db.QueryRowContext(ctx, getLocation, id)
var i Location var i Location
@ -52,6 +58,9 @@ const getLocationExitsFrom = `-- name: GetLocationExitsFrom :many
select id, "to", "from" from exits where from = ? LIMIT 1 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) { func (q *Queries) GetLocationExitsFrom(ctx context.Context, from sql.NullInt64) ([]Exit, error) {
rows, err := q.db.QueryContext(ctx, getLocationExitsFrom, from) rows, err := q.db.QueryContext(ctx, getLocationExitsFrom, from)
if err != nil { if err != nil {
@ -79,6 +88,9 @@ const getLocationExitsTo = `-- name: GetLocationExitsTo :many
select id, "to", "from" from exits where to = ? LIMIT 1 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) { func (q *Queries) GetLocationExitsTo(ctx context.Context, to sql.NullInt64) ([]Exit, error) {
rows, err := q.db.QueryContext(ctx, getLocationExitsTo, to) rows, err := q.db.QueryContext(ctx, getLocationExitsTo, to)
if err != nil { if err != nil {

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

Loading…
Cancel
Save