Documentation ¶
Index ¶
- type DbManager
- type RoomData
- type SqliteManager
- func (mgr *SqliteManager) AddRoom(roomName string) (*RoomData, error)
- func (mgr *SqliteManager) AddSong(song *cmpb.Song) error
- func (mgr *SqliteManager) AddUser(username string, roomId uint32) (*UserData, error)
- func (mgr *SqliteManager) Close()
- func (mgr *SqliteManager) GetRoomByName(roomName string) (*RoomData, error)
- func (mgr *SqliteManager) GetUserById(userId uint32) (*UserData, error)
- func (mgr *SqliteManager) Init(dbPath string) error
- func (mgr *SqliteManager) UpdateUsername(username string, userId uint32) error
- type UserData
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 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.
Click to show internal directories.
Click to hide internal directories.