database

package
v0.0.0-...-2d0791a Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConflictError

func IsConflictError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

func NewMigrations

func NewMigrations(config *config.Config, logger *zap.Logger)

Types

type BucketCreateParams

type BucketCreateParams struct {
	Name                 string
	AllowedMimeTypes     []string
	MaxAllowedObjectSize *int64
	Public               bool
}

type BucketGetObjectCountByIdRow

type BucketGetObjectCountByIdRow struct {
	ID    string
	Count int64
}

type BucketGetSizeByIdRow

type BucketGetSizeByIdRow struct {
	ID   string
	Name string
	Size int64
}

type BucketListPaginatedParams

type BucketListPaginatedParams struct {
	Cursor string
	Limit  int32
}

type BucketLockParams

type BucketLockParams struct {
	LockReason string
	ID         string
}

type BucketUpdateParams

type BucketUpdateParams struct {
	MaxAllowedObjectSize *int64
	Public               *bool
	AllowedMimeTypes     []string
	ID                   string
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type Database

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

func NewDatabasePool

func NewDatabasePool(config *config.Config, logger *zap.Logger) *Database

func (*Database) Close

func (d *Database) Close()

func (*Database) GetDatabase

func (d *Database) GetDatabase() (*pgxpool.Conn, error)

func (*Database) Ping

func (d *Database) Ping() error

type ObjectCreateParams

type ObjectCreateParams struct {
	BucketID     string
	Name         string
	ContentType  *string
	Size         int64
	Metadata     []byte
	UploadStatus string
}

type ObjectGetByBucketIdAndIdParams

type ObjectGetByBucketIdAndIdParams struct {
	BucketID string
	ID       string
}

type ObjectGetByIdWithBucketNameRow

type ObjectGetByIdWithBucketNameRow struct {
	ID             string
	Version        int32
	BucketID       string
	BucketName     string
	Name           string
	MimeType       string
	Size           int64
	Metadata       []byte
	UploadStatus   string
	LastAccessedAt *time.Time
	CreatedAt      time.Time
	UpdatedAt      *time.Time
}

type ObjectSearchByBucketIdAndObjectPathParams

type ObjectSearchByBucketIdAndObjectPathParams struct {
	BucketID   string
	ObjectPath string
	Offset     int32
	Limit      int32
}

type ObjectUpdateParams

type ObjectUpdateParams struct {
	Size     *int64
	MimeType *string
	Metadata []byte
	ID       string
}

type ObjectUpdateUploadStatusParams

type ObjectUpdateUploadStatusParams struct {
	UploadStatus string
	ID           string
}

type ObjectsListBucketIdPagedParams

type ObjectsListBucketIdPagedParams struct {
	BucketID string
	Offset   int32
	Limit    int32
}

type ObjectsListBucketIdPagedRow

type ObjectsListBucketIdPagedRow struct {
	ID             string
	BucketID       string
	Name           string
	MimeType       string
	Size           int64
	Metadata       []byte
	UploadStatus   string
	LastAccessedAt *time.Time
	CreatedAt      time.Time
	UpdatedAt      *time.Time
}

type Querier

type Querier interface {
	BucketCount(ctx context.Context) (int64, error)
	BucketCreate(ctx context.Context, arg *BucketCreateParams) (string, error)
	BucketDelete(ctx context.Context, id string) error
	BucketDisable(ctx context.Context, id string) error
	BucketEnable(ctx context.Context, id string) error
	BucketGetById(ctx context.Context, id string) (*StorageBucket, error)
	BucketGetByName(ctx context.Context, name string) (*StorageBucket, error)
	BucketGetObjectCountById(ctx context.Context, id string) (*BucketGetObjectCountByIdRow, error)
	BucketGetSizeById(ctx context.Context, id string) (*BucketGetSizeByIdRow, error)
	BucketListAll(ctx context.Context) ([]*StorageBucket, error)
	BucketListPaginated(ctx context.Context, arg *BucketListPaginatedParams) ([]*StorageBucket, error)
	BucketLock(ctx context.Context, arg *BucketLockParams) error
	BucketSearch(ctx context.Context, name string) ([]*StorageBucket, error)
	BucketUnlock(ctx context.Context, id string) error
	BucketUpdate(ctx context.Context, arg *BucketUpdateParams) error
	ObjectCreate(ctx context.Context, arg *ObjectCreateParams) (string, error)
	ObjectDelete(ctx context.Context, id string) error
	ObjectGetByBucketIdAndId(ctx context.Context, arg *ObjectGetByBucketIdAndIdParams) (*StorageObject, error)
	ObjectGetById(ctx context.Context, id string) (*StorageObject, error)
	ObjectGetByIdWithBucketName(ctx context.Context, id string) (*ObjectGetByIdWithBucketNameRow, error)
	ObjectGetByName(ctx context.Context, name string) (*StorageObject, error)
	ObjectSearchByBucketIdAndObjectPath(ctx context.Context, arg *ObjectSearchByBucketIdAndObjectPathParams) ([]*StorageObject, error)
	ObjectUpdate(ctx context.Context, arg *ObjectUpdateParams) error
	ObjectUpdateLastAccessedAt(ctx context.Context, id string) error
	ObjectUpdateUploadStatus(ctx context.Context, arg *ObjectUpdateUploadStatusParams) error
	ObjectsListBucketIdPaged(ctx context.Context, arg *ObjectsListBucketIdPagedParams) ([]*ObjectsListBucketIdPagedRow, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) BucketCount

func (q *Queries) BucketCount(ctx context.Context) (int64, error)

func (*Queries) BucketCreate

func (q *Queries) BucketCreate(ctx context.Context, arg *BucketCreateParams) (string, error)

func (*Queries) BucketDelete

func (q *Queries) BucketDelete(ctx context.Context, id string) error

func (*Queries) BucketDisable

func (q *Queries) BucketDisable(ctx context.Context, id string) error

func (*Queries) BucketEnable

func (q *Queries) BucketEnable(ctx context.Context, id string) error

func (*Queries) BucketGetById

func (q *Queries) BucketGetById(ctx context.Context, id string) (*StorageBucket, error)

func (*Queries) BucketGetByName

func (q *Queries) BucketGetByName(ctx context.Context, name string) (*StorageBucket, error)

func (*Queries) BucketGetObjectCountById

func (q *Queries) BucketGetObjectCountById(ctx context.Context, id string) (*BucketGetObjectCountByIdRow, error)

func (*Queries) BucketGetSizeById

func (q *Queries) BucketGetSizeById(ctx context.Context, id string) (*BucketGetSizeByIdRow, error)

func (*Queries) BucketListAll

func (q *Queries) BucketListAll(ctx context.Context) ([]*StorageBucket, error)

func (*Queries) BucketListPaginated

func (q *Queries) BucketListPaginated(ctx context.Context, arg *BucketListPaginatedParams) ([]*StorageBucket, error)

func (*Queries) BucketLock

func (q *Queries) BucketLock(ctx context.Context, arg *BucketLockParams) error

func (*Queries) BucketSearch

func (q *Queries) BucketSearch(ctx context.Context, name string) ([]*StorageBucket, error)

func (*Queries) BucketUnlock

func (q *Queries) BucketUnlock(ctx context.Context, id string) error

func (*Queries) BucketUpdate

func (q *Queries) BucketUpdate(ctx context.Context, arg *BucketUpdateParams) error

func (*Queries) ObjectCreate

func (q *Queries) ObjectCreate(ctx context.Context, arg *ObjectCreateParams) (string, error)

func (*Queries) ObjectDelete

func (q *Queries) ObjectDelete(ctx context.Context, id string) error

func (*Queries) ObjectGetByBucketIdAndId

func (q *Queries) ObjectGetByBucketIdAndId(ctx context.Context, arg *ObjectGetByBucketIdAndIdParams) (*StorageObject, error)

func (*Queries) ObjectGetById

func (q *Queries) ObjectGetById(ctx context.Context, id string) (*StorageObject, error)

func (*Queries) ObjectGetByIdWithBucketName

func (q *Queries) ObjectGetByIdWithBucketName(ctx context.Context, id string) (*ObjectGetByIdWithBucketNameRow, error)

func (*Queries) ObjectGetByName

func (q *Queries) ObjectGetByName(ctx context.Context, name string) (*StorageObject, error)

func (*Queries) ObjectSearchByBucketIdAndObjectPath

func (q *Queries) ObjectSearchByBucketIdAndObjectPath(ctx context.Context, arg *ObjectSearchByBucketIdAndObjectPathParams) ([]*StorageObject, error)

func (*Queries) ObjectUpdate

func (q *Queries) ObjectUpdate(ctx context.Context, arg *ObjectUpdateParams) error

func (*Queries) ObjectUpdateLastAccessedAt

func (q *Queries) ObjectUpdateLastAccessedAt(ctx context.Context, id string) error

func (*Queries) ObjectUpdateUploadStatus

func (q *Queries) ObjectUpdateUploadStatus(ctx context.Context, arg *ObjectUpdateUploadStatusParams) error

func (*Queries) ObjectsListBucketIdPaged

func (q *Queries) ObjectsListBucketIdPaged(ctx context.Context, arg *ObjectsListBucketIdPagedParams) ([]*ObjectsListBucketIdPagedRow, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type StorageBucket

type StorageBucket struct {
	ID                   string
	Version              int32
	Name                 string
	AllowedMimeTypes     []string
	MaxAllowedObjectSize *int64
	Public               bool
	Disabled             bool
	Locked               bool
	LockReason           *string
	LockedAt             *time.Time
	CreatedAt            time.Time
	UpdatedAt            *time.Time
}

type StorageObject

type StorageObject struct {
	ID             string
	Version        int32
	BucketID       string
	Name           string
	MimeType       string
	Size           int64
	Metadata       []byte
	UploadStatus   string
	LastAccessedAt *time.Time
	CreatedAt      time.Time
	UpdatedAt      *time.Time
}

type Transaction

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

func NewTransaction

func NewTransaction(db *pgxpool.Pool) *Transaction

func (*Transaction) WithTransaction

func (t *Transaction) WithTransaction(ctx context.Context, fn func(tx pgx.Tx) error) error

Jump to

Keyboard shortcuts

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