sqlite

package
v0.0.0-...-cea2a50 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MESSAGES = "messages"
View Source
const ROOMS = "rooms"
View Source
const USERS = "users"
View Source
const USER_ROOMS = "user_rooms"

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	ID         int       `db:"id,key,auto"`
	Created    time.Time `db:"created"`
	UserRoomID int       `db:"user_room_id"`
	Payload    string    `db:"payload"`
}

func (*Message) ConvertToReading

func (m *Message) ConvertToReading(nick string) reading.Message

func (*Message) TableName

func (*Message) TableName() string

type Role

type Role string
const (
	Member Role = "Member"
	Admin  Role = "Admin"
)

func (*Role) Scan

func (r *Role) Scan(value interface{}) error

func (Role) Value

func (r Role) Value() (driver.Value, error)

type Room

type Room struct {
	Name string `db:"name,key"`
}

func (*Room) ConvertToReading

func (r *Room) ConvertToReading(messages map[rdn.UserId][]rdn.Message) rdn.Room

func (*Room) TableName

func (*Room) TableName() string

type Storage

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

func NewStorage

func NewStorage(db *godb.DB) Storage

func (*Storage) AddRoom

func (str *Storage) AddRoom(rn string) (string, error)

func (*Storage) AddUserToRoom

func (str *Storage) AddUserToRoom(name string, c *cht.Client) error

func (*Storage) ExcludeFromRoom

func (str *Storage) ExcludeFromRoom(name string, u *cht.Client) error

func (*Storage) GetUser

func (str *Storage) GetUser(ru rdn.UserId) (User, error)

func (*Storage) LoginUser

func (str *Storage) LoginUser(lu auth.LoginUser) (string, error)

func (*Storage) ReadAuthUsers

func (str *Storage) ReadAuthUsers() []auth.AuthUser

func (*Storage) ReadRoom

func (str *Storage) ReadRoom(id string) (rdn.Room, error)

func (*Storage) ReadRooms

func (str *Storage) ReadRooms() ([]rdn.Room, error)

func (*Storage) ReadUser

func (str *Storage) ReadUser(ru rdn.UserId) (rdn.User, error)

func (*Storage) ReadUsers

func (str *Storage) ReadUsers() ([]rdn.User, error)

func (*Storage) RoomHasUser

func (str *Storage) RoomHasUser(name string, c *cht.Client) (bool, int)

func (*Storage) SigninUser

func (str *Storage) SigninUser(u auth.SigninUser) (string, error)

func (*Storage) WriteMessage

func (str *Storage) WriteMessage(u *cht.Client, r *cht.Room, msg string) error

type User

type User struct {
	Created    time.Time      `db:"created"`
	Nick       string         `db:"nick,key"`
	Token      string         `db:"token"`
	Role       Role           `db:"role"`
	Name       sql.NullString `db:"name"`
	SecondName sql.NullString `db:"second_name"`
	Email      sql.NullString `db:"email"`
}

func (*User) ConvertToReading

func (u *User) ConvertToReading() rdn.User

func (*User) ConvertUserToAuth

func (u *User) ConvertUserToAuth() auth.AuthUser

func (*User) GetEmail

func (u *User) GetEmail() string

func (*User) GetName

func (u *User) GetName() string

func (*User) GetSecondName

func (u *User) GetSecondName() string

func (*User) TableName

func (*User) TableName() string

type UserRoom

type UserRoom struct {
	RoomName string `db:"room_name"`
	UserNick string `db:"user_nick"`
	ID       int    `db:"id,key,auto"`
}

func (*UserRoom) TableName

func (*UserRoom) TableName() string

Jump to

Keyboard shortcuts

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