sqlite

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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{}

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{}

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{}

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{}

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 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) 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

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 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