database

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIRepo

func NewAPIRepo(log logger.Logger, db *DB) domain.APIRepo

func NewNotificationRepo

func NewNotificationRepo(log logger.Logger, db *DB) domain.NotificationRepo

func NewSyncRepo

func NewSyncRepo(log logger.Logger, db *DB) domain.SyncRepo

func NewUserRepo

func NewUserRepo(log logger.Logger, db *DB) domain.UserRepo

Types

type APIRepo

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

func (*APIRepo) Delete

func (r *APIRepo) Delete(ctx context.Context, key string) error

func (*APIRepo) Get added in v0.3.0

func (r *APIRepo) Get(ctx context.Context, key string) (*domain.APIKey, error)

func (*APIRepo) GetKeys

func (r *APIRepo) GetKeys(ctx context.Context) ([]domain.APIKey, error)

func (*APIRepo) Store

func (r *APIRepo) Store(ctx context.Context, key *domain.APIKey) error

type DB

type DB struct {
	Driver string
	DSN    string
	// contains filtered or unexported fields
}

func NewDB

func NewDB(cfg *domain.Config, log logger.Logger) (*DB, error)

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Open

func (db *DB) Open() error

func (*DB) Ping

func (db *DB) Ping() error

type ILikeDynamic

type ILikeDynamic interface {
	ToSql() (sql string, args []interface{}, err error)
}

func ILike

func ILike(col string, val string) ILikeDynamic

ILike is a wrapper for sq.Like and sq.ILike SQLite does not support ILike but postgres does so this checks what database is being used

type NotificationRepo

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

func (*NotificationRepo) Delete

func (r *NotificationRepo) Delete(ctx context.Context, notificationID int) error

func (*NotificationRepo) Find

func (*NotificationRepo) FindByID

func (r *NotificationRepo) FindByID(ctx context.Context, id int) (*domain.Notification, error)

func (*NotificationRepo) List

func (*NotificationRepo) Store

func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notification) (*domain.Notification, error)

func (*NotificationRepo) Update

func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notification) (*domain.Notification, error)

type SyncRepo

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

func (SyncRepo) GetSyncDataAndETag added in v1.0.0

func (r SyncRepo) GetSyncDataAndETag(ctx context.Context, apiKey string) ([]byte, *string, error)

Get sync data and etag

func (SyncRepo) GetSyncDataETag added in v1.0.0

func (r SyncRepo) GetSyncDataETag(ctx context.Context, apiKey string) (*string, error)

Get etag of sync data. For avoid memory usage, only the etag will be returned.

func (SyncRepo) SetSyncData added in v1.0.0

func (r SyncRepo) SetSyncData(ctx context.Context, apiKey string, data []byte) (*string, error)

Create or replace sync data, returns the new etag.

func (SyncRepo) SetSyncDataIfMatch added in v1.0.0

func (r SyncRepo) SetSyncDataIfMatch(ctx context.Context, apiKey string, etag string, data []byte) (*string, error)

Replace sync data only if the etag matches, returns the new etag if updated, or nil if not.

type Tx

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

type UserRepo

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

func (*UserRepo) FindByUsername

func (r *UserRepo) FindByUsername(ctx context.Context, username string) (*domain.User, error)

func (*UserRepo) GetUserCount

func (r *UserRepo) GetUserCount(ctx context.Context) (int, error)

func (*UserRepo) Store

func (r *UserRepo) Store(ctx context.Context, user domain.User) error

func (*UserRepo) Update

func (r *UserRepo) Update(ctx context.Context, user domain.User) error

Jump to

Keyboard shortcuts

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