db

package
v0.0.0-...-273060c Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func Open

func Open(source string) (*DB, error)

func (*DB) Acquire

func (db *DB) Acquire(ctx context.Context, user facechat.ID, fn func(tx *Tx) error) error

func (*DB) Close

func (db *DB) Close() error

func (*DB) RAcquire

func (db *DB) RAcquire(ctx context.Context, user facechat.ID, fn func(tx *ReadTx) error) error

type ReadTx

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

func (*ReadTx) IsBlocked

func (tx *ReadTx) IsBlocked(target facechat.ID) error

IsBlocked returns true if target blocked self.

func (*ReadTx) IsInRoom

func (tx *ReadTx) IsInRoom(roomID facechat.ID) error

IsInRoom returns nil if the user is in the room.

func (*ReadTx) IsMutual

func (tx *ReadTx) IsMutual(target facechat.ID) error

IsMutual returns nil if self is a friend of target and target is also a friend of self.

func (*ReadTx) JoinedRooms

func (tx *ReadTx) JoinedRooms() ([]facechat.Room, error)

func (*ReadTx) Messages

func (tx *ReadTx) Messages(roomID, beforeID facechat.ID, limit int) ([]facechat.Message, error)

Messages returns a list of messages ordered by oldest first.

func (*ReadTx) PrivateRooms

func (tx *ReadTx) PrivateRooms() ([]facechat.PrivateRoom, error)

func (*ReadTx) Relationship

func (tx *ReadTx) Relationship(self, target facechat.ID) (facechat.RelationshipType, error)

func (*ReadTx) Room

func (tx *ReadTx) Room(roomID facechat.ID) (*facechat.Room, error)

Room returns a public room. It returns an ErrRoomNotFound if the room is private.

func (*ReadTx) RoomParticipants

func (tx *ReadTx) RoomParticipants(roomID facechat.ID) ([]facechat.ID, error)

func (*ReadTx) SearchRoom

func (tx *ReadTx) SearchRoom(query string) ([]facechat.Room, error)

func (*ReadTx) Session

func (tx *ReadTx) Session(token string) (*facechat.Session, error)

func (*ReadTx) User

func (tx *ReadTx) User(id facechat.ID) (*facechat.User, error)

func (*ReadTx) UserAccounts

func (tx *ReadTx) UserAccounts(id facechat.ID) ([]facechat.Account, error)

func (*ReadTx) UserAccountsLen

func (tx *ReadTx) UserAccountsLen(id facechat.ID) (n int, err error)

type Tx

type Tx struct {
	*ReadTx
}

func (*Tx) AddAccount

func (tx *Tx) AddAccount(acc facechat.Account) error

func (*Tx) AddMessage

func (tx *Tx) AddMessage(msg *facechat.Message) error

func (*Tx) CreateMessage

func (tx *Tx) CreateMessage(room facechat.ID, content string) (*facechat.Message, error)

func (*Tx) CreatePrivateRoom

func (tx *Tx) CreatePrivateRoom(targetUser facechat.ID) (*facechat.Room, error)

func (*Tx) CreatePublicLobby

func (tx *Tx) CreatePublicLobby(name string, lvl facechat.SecretLevel) (*facechat.Room, error)

func (*Tx) JoinRoom

func (tx *Tx) JoinRoom(room facechat.ID) error

func (*Tx) LeaveRoom

func (tx *Tx) LeaveRoom(room facechat.ID) error

func (*Tx) Login

func (tx *Tx) Login(email, password string) (*facechat.Session, error)

func (*Tx) Register

func (tx *Tx) Register(username, password, email string) (*facechat.User, *facechat.Session, error)

func (*Tx) SetRelationship

func (tx *Tx) SetRelationship(targetID facechat.ID, rel facechat.RelationshipType) error

Jump to

Keyboard shortcuts

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