postgres

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatDB

type ChatDB struct {
	sync.Mutex
	*memory.ChatDB
	// contains filtered or unexported fields
}

ChatDB wraps chat.MemoryDB to persist our chats

func NewChatDB

func NewChatDB(p *DB) *ChatDB

NewChatDB constructs ChatDB with parent DB

func (*ChatDB) Add

func (d *ChatDB) Add(chatname string) error

Add ...

func (*ChatDB) LoadChatsFromPostgres

func (d *ChatDB) LoadChatsFromPostgres()

LoadChatsFromPostgres loads chats from postgres

func (*ChatDB) Remove

func (d *ChatDB) Remove(chatname string) error

Remove ...

type DB

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

DB ...

func NewDB

func NewDB(ctx context.Context, connStr string) (*DB, error)

NewDB ...

func (*DB) ApplyMigrations

func (d *DB) ApplyMigrations()

ApplyMigrations applies migrations from dir to create valid tables. First naiive impl, applies all migrations from folder, step by step.

type MessageDB

type MessageDB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MessageDB is db.MessageDB impl

func NewMessageDB

func NewMessageDB(p *DB) *MessageDB

NewMessageDB ...

func (*MessageDB) GetLastNMessages

func (d *MessageDB) GetLastNMessages(chatname string, n int) ([]*models.Message, error)

GetLastNMessages ... should return empty slice even on error

func (*MessageDB) Post

func (d *MessageDB) Post(m *models.Message) error

Post ... should update message ID and time

type UserDB

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

UserDB is a sub db, that uses pool from DB.

func NewUserDB

func NewUserDB(p *DB) *UserDB

NewUserDB constructs ChatDB with parent DB

func (*UserDB) Get

func (d *UserDB) Get(username string) (models.FullUser, error)

Get ...

func (*UserDB) Store

func (d *UserDB) Store(u models.FullUser) error

Store ...

func (*UserDB) Update

func (d *UserDB) Update(u models.FullUser) error

Update ...

Jump to

Keyboard shortcuts

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