sqlite

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VecDB          *VectorDBVec
	VecInitialized bool
	VecMutex       sync.Mutex
)

VEC相关全局变量

Functions

func InitVecDB added in v0.6.0

func InitVecDB(dbPath string) error

func Migrate

func Migrate(ds *SQLite, m Migration) error

func MigrateToLatest

func MigrateToLatest(vm VersionManager, ds *SQLite) error

MigrateToLatest

func RegisterMigration

func RegisterMigration(m Migration)

RegisterMigration

Types

type LocalTimePlugin added in v0.7.0

type LocalTimePlugin struct{}

LocalTimePlugin is a GORM plugin for automatically setting LocalTime type timestamp fields

func (*LocalTimePlugin) Initialize added in v0.7.0

func (p *LocalTimePlugin) Initialize(db *gorm.DB) error

Initialize initializes the plugin and registers callbacks

func (*LocalTimePlugin) Name added in v0.7.0

func (p *LocalTimePlugin) Name() string

Name returns the plugin name

type Migration

type Migration interface {
	Version() string
	GetModifyFields(tableName string) map[string]string
	ExtraDataOperation(ds *SQLite) error
}

type MigrationV1

type MigrationV1 struct{}

MigrationV1 example

func (*MigrationV1) ExtraDataOperation

func (m *MigrationV1) ExtraDataOperation(ds *SQLite) error

func (*MigrationV1) GetModifyFields

func (m *MigrationV1) GetModifyFields(tableName string) map[string]string

func (*MigrationV1) Version

func (m *MigrationV1) Version() string

The version should match the corresponding AOG version.

type MigrationV2

type MigrationV2 struct{}

MigrationV1 example

func (*MigrationV2) ExtraDataOperation

func (m *MigrationV2) ExtraDataOperation(ds *SQLite) error

func (*MigrationV2) GetModifyFields

func (m *MigrationV2) GetModifyFields(tableName string) map[string]string

func (*MigrationV2) Version

func (m *MigrationV2) Version() string

type MigrationV3

type MigrationV3 struct{}

MigrationV1 example

func (*MigrationV3) ExtraDataOperation

func (m *MigrationV3) ExtraDataOperation(ds *SQLite) error

func (*MigrationV3) GetModifyFields

func (m *MigrationV3) GetModifyFields(tableName string) map[string]string

func (*MigrationV3) Version

func (m *MigrationV3) Version() string

type MigrationV4

type MigrationV4 struct{}

MigrationV1 example

func (*MigrationV4) ExtraDataOperation

func (m *MigrationV4) ExtraDataOperation(ds *SQLite) error

func (*MigrationV4) GetModifyFields

func (m *MigrationV4) GetModifyFields(tableName string) map[string]string

func (*MigrationV4) Version

func (m *MigrationV4) Version() string

type MigrationV5

type MigrationV5 struct{}

MigrationV1 example

func (*MigrationV5) ExtraDataOperation

func (m *MigrationV5) ExtraDataOperation(ds *SQLite) error

func (*MigrationV5) GetModifyFields

func (m *MigrationV5) GetModifyFields(tableName string) map[string]string

func (*MigrationV5) Version

func (m *MigrationV5) Version() string

type MigrationV6 added in v0.7.0

type MigrationV6 struct{} // Phase 3: Plugin support

MigrationV1 example

func (*MigrationV6) ExtraDataOperation added in v0.7.0

func (m *MigrationV6) ExtraDataOperation(ds *SQLite) error

func (*MigrationV6) GetModifyFields added in v0.7.0

func (m *MigrationV6) GetModifyFields(tableName string) map[string]string

MigrationV6: Phase 3 Plugin support Add plugin-related fields and tables

func (*MigrationV6) Version added in v0.7.0

func (m *MigrationV6) Version() string

type MigrationV7 added in v0.7.0

type MigrationV7 struct{} // text-to-image migration from gRPC to HTTP

MigrationV1 example

func (*MigrationV7) ExtraDataOperation added in v0.7.0

func (m *MigrationV7) ExtraDataOperation(ds *SQLite) error

func (*MigrationV7) GetModifyFields added in v0.7.0

func (m *MigrationV7) GetModifyFields(tableName string) map[string]string

MigrationV7: text-to-image service migration from gRPC to HTTP

func (*MigrationV7) Version added in v0.7.0

func (m *MigrationV7) Version() string

type SQLite

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

SQLite implements the Datastore interface

func New

func New(dbPath string) (*SQLite, error)

New creates a new SQLite instance

func (*SQLite) Add

func (ds *SQLite) Add(ctx context.Context, entity datastore.Entity) error

Add inserts a record

func (*SQLite) BatchAdd

func (ds *SQLite) BatchAdd(ctx context.Context, entities []datastore.Entity) error

BatchAdd inserts multiple records

func (*SQLite) Commit

func (ds *SQLite) Commit(ctx context.Context) error

Commit commits the transaction

func (*SQLite) Count

func (ds *SQLite) Count(ctx context.Context, entity datastore.Entity, options *datastore.FilterOptions) (int64, error)

Count counts the number of records

func (*SQLite) Delete

func (ds *SQLite) Delete(ctx context.Context, entity datastore.Entity) error

Delete removes a record

func (*SQLite) Get

func (ds *SQLite) Get(ctx context.Context, entity datastore.Entity) error

Get retrieves a single record

func (*SQLite) GetDB added in v0.6.0

func (ds *SQLite) GetDB() *gorm.DB

GetDB exposes the underlying *gorm.DB for advanced queries (e.g., vector search)

func (*SQLite) Init

func (ds *SQLite) Init() error

Init TODO need to consider table structure changes here

func (*SQLite) IsExist

func (ds *SQLite) IsExist(ctx context.Context, entity datastore.Entity) (bool, error)

IsExist checks if a record exists

func (*SQLite) List

func (ds *SQLite) List(ctx context.Context, entity datastore.Entity, options *datastore.ListOptions) ([]datastore.Entity, error)

List queries multiple records

func (*SQLite) Put

func (ds *SQLite) Put(ctx context.Context, entity datastore.Entity) error

Put updates or inserts a record (upsert operation)

type SQLiteVersionManager

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

SQLiteVersionManager 实现 VersionManager 接口,基于 version_update_record 表

func NewSQLiteVersionManager

func NewSQLiteVersionManager(ds *SQLite) *SQLiteVersionManager

func (*SQLiteVersionManager) GetCurrentVersion

func (vm *SQLiteVersionManager) GetCurrentVersion() (string, error)

func (*SQLiteVersionManager) SetCurrentVersion

func (vm *SQLiteVersionManager) SetCurrentVersion(version string) error

type VectorDBVec added in v0.6.0

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

func NewVectorDBVec added in v0.6.0

func NewVectorDBVec(dbPath string) (*VectorDBVec, error)

func (*VectorDBVec) Close added in v0.6.0

func (vdb *VectorDBVec) Close() error

Close 关闭数据库连接并释放资源

func (*VectorDBVec) DeleteChunks added in v0.6.0

func (vdb *VectorDBVec) DeleteChunks(ctx context.Context, chunkIDs []string) error

DeleteChunks 从数据库中删除指定ID的文件块

func (*VectorDBVec) GetChunkByID added in v0.6.0

func (vdb *VectorDBVec) GetChunkByID(ctx context.Context, id string) (content string, chunkID string, err error)

GetChunkByID 通过主键 id 精确查询 file_chunks 内容

func (*VectorDBVec) Initialize added in v0.6.0

func (vdb *VectorDBVec) Initialize() error

Initialize 初始化向量数据库结构

func (*VectorDBVec) SearchSimilarChunks added in v0.6.0

func (vdb *VectorDBVec) SearchSimilarChunks(ctx context.Context, query []float32, limit int, fileIDList []string) ([]string, []float64, error)

SearchSimilarChunks 在 file_chunks 表的 embedding 字段做向量检索

func (*VectorDBVec) SearchSimilarChunksByText added in v0.6.0

func (vdb *VectorDBVec) SearchSimilarChunksByText(ctx context.Context, queryText string, limit int, fileIDList []string) ([]string, []float64, error)

SearchSimilarChunksByText 使用文本搜索作为向量搜索的备选方案

type VersionManager

type VersionManager interface {
	GetCurrentVersion() (string, error)
	SetCurrentVersion(version string) error
}

VersionManager

Jump to

Keyboard shortcuts

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