Documentation ¶
Overview ¶
Package db contains the database implementation for legato.
Index ¶
- Constants
- Variables
- func TryWrap(e error, msg string, args ...interface{}) error
- func Wrap(e error, msg string, args ...interface{}) error
- type ChannelKind
- type DB
- func (db *DB) CreateChannel(ctx context.Context, guildID uint64, name string, kind ChannelKind) (models.Channel, error)
- func (db *DB) CreateGuild(ctx context.Context, name string, picture *string, ownerID uint64, ...) (models.Guild, error)
- func (db *DB) CreateUser(ctx context.Context, email string, username string, passwordHash []byte) (uint64, error)
- func (db *DB) GetAuthStep(ctx context.Context, sessionID string) (int, error)
- func (db *DB) GetChannel(ctx context.Context)
- func (db *DB) GetChannelList(ctx context.Context, guildID uint64) ([]models.Channel, error)
- func (db *DB) GetGuildList(ctx context.Context, userID uint64) ([]models.GetGuildListRow, error)
- func (db *DB) GetGuildMember(ctx context.Context)
- func (db *DB) GetGuildMembers(ctx context.Context, guildID uint64) ([]models.GetGuildMembersRow, error)
- func (db *DB) GetGuildsById(ctx context.Context, guildIds []uint64) ([]models.Guild, error)
- func (db *DB) GetUserByEmail(ctx context.Context, email string) (models.GetUserByEmailRow, error)
- func (db *DB) GetUserByID(ctx context.Context, id uint64) (models.User, error)
- func (db *DB) GetUserForSession(ctx context.Context, sessionID string) (uint64, error)
- func (db *DB) HasSharedGuilds(ctx context.Context, user1 uint64, user2 uint64) (bool, error)
- func (db *DB) IsGuildMember(ctx context.Context)
- func (db *DB) PublishAuth(ctx context.Context, sessionID string, event *gen.AuthMessage) error
- func (db *DB) PublishChatEvent(ctx context.Context, guildID uint64, event *chatv1.StreamEvent) error
- func (db *DB) PublishUserEvent(ctx context.Context, userID uint64, event *chatv1.StreamEvent) error
- func (db *DB) RemoveGuildFromList(ctx context.Context)
- func (db *DB) RemoveGuildMember(ctx context.Context, guildID uint64, userID uint64, reason chatv1.LeaveReason) error
- func (db *DB) SaveSession(ctx context.Context, sessionID string, token string, userID uint64) error
- func (db *DB) SetAuthStep(ctx context.Context, sessionID string, step int) error
- func (db *DB) StreamChatEvents(ctx context.Context, userID uint64, guilds []uint64) chan *chatv1.StreamEvent
- func (db *DB) StreamUserSteps(ctx context.Context, sessionID string) chan *gen.AuthMessage
- func (db *DB) SubscribeStream(ctx context.Context, userID uint64, topics ...string) error
- type GuildKind
Constants ¶
View Source
const ( GuildKindGuild = iota GuildKindRoom GuildKindDM )
View Source
const ( ChannelKindNormal = iota ChannelKindVoice ChannelKindCategory )
Variables ¶
View Source
var Migrations embed.FS
Functions ¶
Types ¶
type ChannelKind ¶
type ChannelKind int16
type DB ¶
type DB struct { Rdb *redis.Client Postgres *pgxpool.Pool // contains filtered or unexported fields }
DB is the database structure.
func (*DB) CreateChannel ¶
func (*DB) CreateGuild ¶
func (*DB) CreateUser ¶
func (db *DB) CreateUser(ctx context.Context, email string, username string, passwordHash []byte) (uint64, error)
CreateUser saves a user to the database.
func (*DB) GetAuthStep ¶
func (*DB) GetChannel ¶
func (*DB) GetChannelList ¶
func (*DB) GetGuildList ¶
func (*DB) GetGuildMember ¶
func (*DB) GetGuildMembers ¶
func (*DB) GetGuildsById ¶
func (*DB) GetUserByEmail ¶
func (*DB) GetUserByID ¶
func (*DB) GetUserForSession ¶
func (*DB) HasSharedGuilds ¶
func (*DB) IsGuildMember ¶
func (*DB) PublishAuth ¶
func (*DB) PublishChatEvent ¶
func (*DB) PublishUserEvent ¶
func (*DB) RemoveGuildFromList ¶
func (*DB) RemoveGuildMember ¶
func (*DB) SaveSession ¶
func (*DB) SetAuthStep ¶
SetAuthStep saves to redis the auth session and step the user is on.
func (*DB) StreamChatEvents ¶
func (*DB) StreamUserSteps ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.