dbrepo

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package dbrepo contains shared database opening primitives for tld stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyEmbeddedMigrations

func ApplyEmbeddedMigrations(ctx context.Context, db *bun.DB, migrations embed.FS, dir string) error

Types

type DBOptions

type DBOptions struct {
	Dialect       Dialect
	SQLitePath    string
	DatabaseURL   string
	SchemaProfile SchemaProfile
	Migrations    embed.FS
}

type Dialect

type Dialect string
const (
	DialectSQLite   Dialect = "sqlite"
	DialectPostgres Dialect = "postgres"
)

type Handle

type Handle struct {
	DB            *sql.DB
	Bun           *bun.DB
	Dialect       Dialect
	SchemaProfile SchemaProfile
}

func Open

func Open(ctx context.Context, opts DBOptions) (*Handle, error)

func OpenPostgres

func OpenPostgres(ctx context.Context, opts DBOptions) (*Handle, error)

func OpenSQLite

func OpenSQLite(ctx context.Context, opts DBOptions) (*Handle, error)

func (*Handle) Close

func (h *Handle) Close() error

type SchemaProfile

type SchemaProfile string
const (
	SchemaLocal SchemaProfile = "local"
	SchemaCloud SchemaProfile = "cloud"
)

type VectorStore

type VectorStore interface {
	EnsureSchema(ctx context.Context) error
	Save(ctx context.Context, modelID int64, ownerType, ownerKey, inputHash string, vectorData []byte) error
	Similar(ctx context.Context, modelID int64, query []float32, limit int) ([]int64, error)
}

Jump to

Keyboard shortcuts

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