data

package
v0.0.0-...-7be24de Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbDir

func DbDir() string

DbDir returns '$HOME/.GoChat/data'.

func DbPath

func DbPath() string

DbPath returns '$HOME/.GoChat/data/gochat.sqlite'.

func IsNotExist

func IsNotExist() bool

IsNotExist returns true if the file '$HOME/.GoChat/data/gochat.sqlite' doesn't exists, otherwise false.

Types

type Group

type Group struct {
	Id        int       `db:"ID" json:"id" form:"id" uri:"id"`
	UUId      string    `db:"UUID" json:"uuid" form:"uuid"`
	Name      string    `db:"NAME" json:"name" form:"name"`
	AdminId   int       `db:"ADMIN_ID" json:"admin_id"`
	Token     string    `db:"TOKEN" json:"token"`
	CreatedAt time.Time `db:"CREATED_AT" json:"created_at"`
}

func GroupByUniqueKey

func GroupByUniqueKey(key string, value interface{}) (g Group, err error)

func Groups

func Groups(limit int) (gs []Group, err error)

func (*Group) Administrator

func (g *Group) Administrator() (u User, err error)

func (*Group) Delete

func (g *Group) Delete() (err error)

func (*Group) HasMember

func (g *Group) HasMember(u User) bool

func (*Group) Members

func (g *Group) Members() (us []User, err error)

func (*Group) Update

func (g *Group) Update() (err error)

type RoleType

type RoleType int
const (
	RoleTypeOwner RoleType = 4
	RoleTypeAdmin RoleType = 2
	RoleTypeGuest RoleType = 0
)

type Session

type Session struct {
	Id        int       `db:"ID" json:"id" form:"id" uri:"id"`
	UUId      string    `db:"UUID" json:"uuid" form:"uuid"`
	UserId    int       `db:"USER_ID" json:"user_id" form:"user_id"`
	CreatedAt time.Time `db:"CREATED_AT" json:"created_at"`
}

func SessionByUniqueKey

func SessionByUniqueKey(key string, value interface{}) (s Session, err error)

func Sessions

func Sessions(limit int) (ss []Session, err error)

func (*Session) Delete

func (s *Session) Delete() (err error)

func (*Session) User

func (s *Session) User() (u User, err error)

type User

type User struct {
	Id        int       `db:"ID" json:"id" form:"id" uri:"id"`
	UUId      string    `db:"UUID" json:"uuid" form:"uuid"`
	Name      string    `db:"NAME" json:"name" form:"name"`
	Password  string    `db:"PASSWORD" json:"password"`
	MaxRole   RoleType  `db:"MAX_ROLE" json:"max_role"`
	CreatedAt time.Time `db:"CREATED_AT" json:"created_at"`
}

func UserByUniqueKey

func UserByUniqueKey(key string, value interface{}) (u User, err error)

func Users

func Users(limit int) (us []User, err error)

func (*User) Create

func (u *User) Create() (err error)

func (*User) CreateGroup

func (u *User) CreateGroup(name string, token string) (g Group, err error)

func (*User) CreateSession

func (u *User) CreateSession() (s Session, err error)

func (*User) CreatedGroups

func (u *User) CreatedGroups() (gs []Group, err error)

func (*User) Delete

func (u *User) Delete() (err error)

func (*User) JoinGroup

func (u *User) JoinGroup(g Group) (err error)

func (*User) JoinedGroups

func (u *User) JoinedGroups() (gs []Group, err error)

func (*User) LeaveGroup

func (u *User) LeaveGroup(g Group) (err error)

func (*User) Session

func (u *User) Session() (s Session, err error)

func (*User) Update

func (u *User) Update() (err error)

Jump to

Keyboard shortcuts

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