database

package
v0.0.0-...-eb082ec Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("not found")
	ErrNotUnique = errors.New("not unique")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	PrimaryUs        string
	ReplicaEu        string
	ReplicaAsia      string
	FlyRegion        string
	Logger           *zap.Logger
	PlanetscaleBoost bool
}

type Database

type Database interface {
	CreateApi(ctx context.Context, newApi entities.Api) error
	GetApi(ctx context.Context, apiId string) (entities.Api, error)
	GetApiByKeyAuthId(ctx context.Context, keyAuthId string) (entities.Api, error)

	CreateKey(ctx context.Context, newKey entities.Key) error
	UpdateKey(ctx context.Context, key entities.Key) error

	DeleteKey(ctx context.Context, keyId string) error
	GetKeyByHash(ctx context.Context, hash string) (entities.Key, error)
	GetKeyById(ctx context.Context, keyId string) (entities.Key, error)
	CountKeys(ctx context.Context, keyAuthId string) (int, error)
	ListKeysByKeyAuthId(ctx context.Context, keyAuthId string, limit int, offset int, ownerId string) ([]entities.Key, error)
	CreateWorkspace(ctx context.Context, newWorkspace entities.Workspace) error

	CreateKeyAuth(ctx context.Context, newKeyAuth entities.KeyAuth) error
	GetKeyAuth(ctx context.Context, keyAuthId string) (entities.KeyAuth, error)

	GetWorkspace(ctx context.Context, workspaceId string) (entities.Workspace, error)
	DecrementRemainingKeyUsage(ctx context.Context, keyId string) (int64, error)
}

func New

func New(config Config) (Database, error)

Directories

Path Synopsis
Package models contains generated code for schema 'unkey'.
Package models contains generated code for schema 'unkey'.

Jump to

Keyboard shortcuts

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