db

package
v0.0.0-...-f808dbb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbInit

func DbInit() error

DbInit is so when we share one sql.Open for various db calls throughout the program. Also, it means we don't have to handle an err on said subsequent db calls

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type InsertRoomParams

type InsertRoomParams struct {
	Name     string
	Password string
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func Db

func Db() *Queries

func New

func New(db DBTX) *Queries

func (*Queries) DeleteRoom

func (q *Queries) DeleteRoom(ctx context.Context, id int64) error

DeleteRoom

DELETE FROM rooms WHERE id = ?

func (*Queries) InsertRoom

func (q *Queries) InsertRoom(ctx context.Context, arg InsertRoomParams) (Room, error)

table: rooms

INSERT OR IGNORE INTO rooms (name, password) VALUES (?, ?) RETURNING id, name, password, currently_playing

func (*Queries) SelectCurrentVideoByRoomId

func (q *Queries) SelectCurrentVideoByRoomId(ctx context.Context, id int64) (SelectCurrentVideoByRoomIdRow, error)

SelectCurrentVideoByRoomId

SELECT video.uri, video.local FROM rooms
JOIN video ON rooms.currently_playing = video.id
WHERE rooms.id = ?

func (*Queries) SelectRoomById

func (q *Queries) SelectRoomById(ctx context.Context, id int64) (Room, error)

SelectRoomById

SELECT id, name, password, currently_playing FROM rooms WHERE id = ?

func (*Queries) SelectRoomByName

func (q *Queries) SelectRoomByName(ctx context.Context, name string) (Room, error)

SelectRoomByName

SELECT id, name, password, currently_playing FROM rooms WHERE name = ?

func (*Queries) SelectRoomByNameWithPassword

func (q *Queries) SelectRoomByNameWithPassword(ctx context.Context, name string) (SelectRoomByNameWithPasswordRow, error)

SelectRoomByNameWithPassword

SELECT id, name, password, currently_playing, password FROM rooms WHERE name = ?

func (*Queries) UpdateRoomNameById

func (q *Queries) UpdateRoomNameById(ctx context.Context, arg UpdateRoomNameByIdParams) error

UpdateRoomNameById

UPDATE rooms SET name = ? WHERE id = ?

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Room

type Room struct {
	ID               int64
	Name             string
	Password         string
	CurrentlyPlaying *int64
}

type RoomHistory

type RoomHistory struct {
	RoomID  *int64
	VideoID *int64
}

type SelectCurrentVideoByRoomIdRow

type SelectCurrentVideoByRoomIdRow struct {
	Uri   string
	Local bool
}

type SelectRoomByNameWithPasswordRow

type SelectRoomByNameWithPasswordRow struct {
	ID               int64
	Name             string
	Password         string
	CurrentlyPlaying *int64
	Password_2       string
}

type UpdateRoomNameByIdParams

type UpdateRoomNameByIdParams struct {
	Name string
	ID   int64
}

type Video

type Video struct {
	ID    int64
	Uri   string
	Local bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL