db

package
v0.0.0-...-bcea4d5 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDBTenant = errors.New("db is not configured with provided tenant")
	ErrNoDBVault  = errors.New("db is not configured with provided vault")
)
View Source
var (
	ErrObjectTypeNotRegistered = errors.New("object type not registered - use NewObjectSet to access vaults")
)

Functions

func Close

func Close() (err error)

func DBs

func DBs(vault Vault, tenant convAuth.Tenant) ([]*sql.DB, error)

func Open

func Open() (err error)

func Where

func Where() whereExpectingFirstStatement

Types

type Engine

type Engine string
const (
	EnginePostgres Engine = "postgres"
	EngineSqlite   Engine = "sqlite"
)

type Key

type Key[idT, shardKeyT ~string] struct {
	ID       idT
	ShardKey shardKeyT
}

type Lock

type Lock[objT Object[idT, shardKeyT], idT, shardKeyT ~string] struct {
	// contains filtered or unexported fields
}

func (Lock[objT, idT, shardKeyT]) Unlock

func (l Lock[objT, idT, shardKeyT]) Unlock() (err error)

type Metadata

type Metadata struct {
	CreatedAt time.Time     `json:"created_at"`
	CreatedBy convAuth.User `json:"created_by"`
	UpdatedAt time.Time     `json:"updated_at"`
	UpdatedBy convAuth.User `json:"updated_by"`
}

type Object

type Object[idT, shardKeyT ~string] interface {
	DBKey() Key[idT, shardKeyT]
}

type ObjectSet

type ObjectSet[objT Object[idT, shardKeyT], idT, shardKeyT ~string] struct {
	// contains filtered or unexported fields
}

func NewObjectSet

func NewObjectSet[objT Object[idT, shardKeyT], idT ~string, shardKeyT ~string](vault Vault, textSearch bool, indexes ...string) ObjectSet[objT, idT, shardKeyT]

func (ObjectSet[objT, idT, shardKeyT]) Tenant

func (os ObjectSet[objT, idT, shardKeyT]) Tenant(tenant convAuth.Tenant) TenantObjectSet[objT, idT, shardKeyT]

type TenantObjectSet

type TenantObjectSet[objT Object[idT, shardKeyT], idT, shardKeyT ~string] struct {
	ObjectSet[objT, idT, shardKeyT]
	// contains filtered or unexported fields
}

func (TenantObjectSet[objT, idT, shardKeyT]) Delete

func (tos TenantObjectSet[objT, idT, shardKeyT]) Delete(ctx convCtx.Context, id idT, shardKeys ...shardKeyT) (err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Insert

func (tos TenantObjectSet[objT, idT, shardKeyT]) Insert(ctx convCtx.Context, obj objT) (err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Lock

func (tos TenantObjectSet[objT, idT, shardKeyT]) Lock(ctx convCtx.Context, obj objT, desc string) (lock *Lock[objT, idT, shardKeyT], err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Metadata

func (tos TenantObjectSet[objT, idT, shardKeyT]) Metadata(ctx convCtx.Context, id idT, shardKeys ...shardKeyT) (res *Metadata, err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Process

func (tos TenantObjectSet[objT, idT, shardKeyT]) Process(ctx convCtx.Context, where whereReady, process func(ctx convCtx.Context, obj objT) error, shardKeys ...shardKeyT) (count int, err error)

func (TenantObjectSet[objT, idT, shardKeyT]) SafeUpdate

func (tos TenantObjectSet[objT, idT, shardKeyT]) SafeUpdate(ctx convCtx.Context, from, to objT) (err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Select

func (tos TenantObjectSet[objT, idT, shardKeyT]) Select(ctx convCtx.Context, where whereReady, shardKeys ...shardKeyT) (obs []objT, err error)

func (TenantObjectSet[objT, idT, shardKeyT]) SelectAll

func (tos TenantObjectSet[objT, idT, shardKeyT]) SelectAll(ctx convCtx.Context) (obs []objT, err error)

func (TenantObjectSet[objT, idT, shardKeyT]) SelectByID

func (tos TenantObjectSet[objT, idT, shardKeyT]) SelectByID(ctx convCtx.Context, id idT, shardKeys ...shardKeyT) (obj *objT, err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Update

func (tos TenantObjectSet[objT, idT, shardKeyT]) Update(ctx convCtx.Context, obj objT) (err error)

func (TenantObjectSet[objT, idT, shardKeyT]) Upsert

func (tos TenantObjectSet[objT, idT, shardKeyT]) Upsert(ctx convCtx.Context, obj objT) (err error)

type Vault

type Vault string

Jump to

Keyboard shortcuts

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