database

package
v0.0.0-...-23f444a Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbManager

type DbManager interface {
	// Add a new song to the database
	AddSong(song *cmpb.Song) error

	// Add a new user to the users table and returns the user's id
	AddUser(username string, roomId uint32) (*UserData, error)

	// Add a new room to the database
	AddRoom(roomName string) (*RoomData, error)

	// Close the database connection
	Close()

	// Get user by id
	GetUserById(userId uint32) (*UserData, error)

	// Updates the given user's name
	UpdateUsername(username string, userId uint32) error

	// Queries for a room given its name
	GetRoomByName(roomName string) (*RoomData, error)

	// Initialize the database interface
	Init(dbPath string) error
}

* Interface for manager the backend database

type RoomData

type RoomData struct {
	Room       bepb.Room
	CreateDate time.Time
	LastAccess time.Time
}

type SqliteManager

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

func (*SqliteManager) AddRoom

func (mgr *SqliteManager) AddRoom(roomName string) (*RoomData, error)

* Adds a new room with given name

func (*SqliteManager) AddSong

func (mgr *SqliteManager) AddSong(song *cmpb.Song) error

* Add a new song to the database

func (*SqliteManager) AddUser

func (mgr *SqliteManager) AddUser(username string, roomId uint32) (*UserData, error)

* Add a new user to the database

func (*SqliteManager) Close

func (mgr *SqliteManager) Close()

* Clean up resources used by the database manager

func (*SqliteManager) GetRoomByName

func (mgr *SqliteManager) GetRoomByName(roomName string) (*RoomData, error)

func (*SqliteManager) GetUserById

func (mgr *SqliteManager) GetUserById(userId uint32) (*UserData, error)

* Query for the user data of the given user id

func (*SqliteManager) Init

func (mgr *SqliteManager) Init(dbPath string) error

* Initialize the sqlite database

func (*SqliteManager) UpdateUsername

func (mgr *SqliteManager) UpdateUsername(username string, userId uint32) error

* Updates the username of an existing user.

type UserData

type UserData struct {
	User       bepb.User
	LoggedIn   bool
	LastAccess time.Time
}

Jump to

Keyboard shortcuts

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