postgres

package
v0.0.0-...-64046f9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseStore

type BaseStore struct {
	*sql.DB
	store.Txier
}

BaseStore define base store

type ChatStore

type ChatStore struct {
	BaseStore
}

func (*ChatStore) Add

func (store *ChatStore) Add(ctx context.Context, chat *core.Chat) error

Add chat to store.

func (*ChatStore) Query

func (store *ChatStore) Query() core.ChatStoreQuery

func (*ChatStore) Update

func (store *ChatStore) Update(ctx context.Context, chat *core.Chat) error

Update chat in store.

type ChatStoreQuery

type ChatStoreQuery struct {
	Store *ChatStore
	Mods  []qm.QueryMod
}

func (*ChatStoreQuery) All

func (csq *ChatStoreQuery) All(ctx context.Context) ([]*core.Chat, error)

All query items from store.

func (*ChatStoreQuery) Count

func (csq *ChatStoreQuery) Count(ctx context.Context) (int, error)

Count items in store.

func (*ChatStoreQuery) Delete

func (csq *ChatStoreQuery) Delete(ctx context.Context) (int, error)

func (*ChatStoreQuery) ID

func (csq *ChatStoreQuery) ID(ids ...core.ChatID) core.ChatStoreQuery

ID Filter

func (*ChatStoreQuery) One

func (csq *ChatStoreQuery) One(ctx context.Context) (*core.Chat, error)

One return only one item from store.

func (*ChatStoreQuery) OwnerID

func (csq *ChatStoreQuery) OwnerID(id core.UserID) core.ChatStoreQuery

OwnerID filter

func (*ChatStoreQuery) TelegramID

func (csq *ChatStoreQuery) TelegramID(id int64) core.ChatStoreQuery

TelegramID filter

type DownloadStore

type DownloadStore struct {
	BaseStore
}

func (*DownloadStore) Add

func (store *DownloadStore) Add(ctx context.Context, dwn *core.Download) error

func (*DownloadStore) GetChatStats

func (store *DownloadStore) GetChatStats(ctx context.Context, id core.ChatID) (*core.ChatDownloadStats, error)

func (*DownloadStore) GetFileStats

func (store *DownloadStore) GetFileStats(ctx context.Context, id core.FileID) (*core.FileDownloadStats, error)

func (*DownloadStore) Query

func (store *DownloadStore) Query() core.DownloadStoreQuery

type FileStore

type FileStore struct {
	BaseStore
}

func (*FileStore) Add

func (store *FileStore) Add(ctx context.Context, file *core.File) error

func (*FileStore) Query

func (store *FileStore) Query() core.FileStoreQuery

func (*FileStore) Update

func (store *FileStore) Update(ctx context.Context, file *core.File) error

type Postgres

type Postgres struct {
	*sql.DB
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB) *Postgres

New create postgres based database with all stores.

func (*Postgres) Chat

func (pg *Postgres) Chat() core.ChatStore

func (*Postgres) Download

func (pg *Postgres) Download() core.DownloadStore

func (*Postgres) File

func (pg *Postgres) File() core.FileStore

func (*Postgres) Migrator

func (pg *Postgres) Migrator() store.Migrator

func (*Postgres) Tx

func (pg *Postgres) Tx(ctx context.Context, txFunc store.TxFunc) (err error)

Tx run code in database transaction. Based on: https://stackoverflow.com/a/23502629.

func (*Postgres) User

func (pg *Postgres) User() core.UserStore

type UserStore

type UserStore struct {
	BaseStore
}

func (*UserStore) Add

func (store *UserStore) Add(ctx context.Context, user *core.User) error

func (*UserStore) Find

func (store *UserStore) Find(ctx context.Context, id core.UserID) (*core.User, error)

func (*UserStore) Query

func (store *UserStore) Query() core.UserStoreQuery

func (*UserStore) RefStats

func (store *UserStore) RefStats(ctx context.Context) (core.UserRefStats, error)

func (*UserStore) Update

func (store *UserStore) Update(ctx context.Context, user *core.User) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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