database

package
v0.0.0-...-a10b1fc Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *sql.DB

Functions

func AddUserInRoom

func AddUserInRoom(token string, userId int) error

func CreateMessage

func CreateMessage(userId int, message string, roomId int) error

NOTE: -1 means public room

func CreateRoom

func CreateRoom(userId int, name string, token string) error

func CreateUser

func CreateUser(name, password string) error

func InitDB

func InitDB() error

func IsUserInRoom

func IsUserInRoom(roomId, userId int) error

Types

type Message

type Message struct {
	Id        int    `json:"id"`
	UserId    int    `json:"user_id"`
	Message   string `json:"message"`
	CreatedAt string `json:"created_at"`
}

type MessageWithUser

type MessageWithUser struct {
	Id        int    `json:"id"`
	Username  string `json:"username"`
	UserId    int    `json:"user_id"`
	Message   string `json:"message"`
	CreatedAt string `json:"created_at"`
}

func GetRoomMessagesInRoom

func GetRoomMessagesInRoom(roomId int) ([]MessageWithUser, error)

type Room

type Room struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	Token string `json:"token"`
}

func FindRoomByToken

func FindRoomByToken(token string) (Room, error)

func UserRooms

func UserRooms(userId int) ([]Room, error)

type RoomNotFound

type RoomNotFound struct{}

func (*RoomNotFound) Error

func (*RoomNotFound) Error() string

type User

type User struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	Password  string `json:"password"`
	CreatedAt string `json:"created_at"`
}

func FindUserById

func FindUserById(id int) (User, error)

func FindUserByName

func FindUserByName(name string) (User, error)

type UserNotFound

type UserNotFound struct{}

func (*UserNotFound) Error

func (*UserNotFound) Error() string

Jump to

Keyboard shortcuts

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