persistence

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PqForeignKeyViolation  = pq.ErrorCode("23503")
	PqUniqueViolationError = pq.ErrorCode("23505")
)

Variables

This section is empty.

Functions

func NewMigration

func NewMigration(driverName, dataSourceName string) *migration

Types

type AnyMap added in v0.0.2

type AnyMap map[string]any

func (*AnyMap) Scan added in v0.0.2

func (m *AnyMap) Scan(value any) error

func (AnyMap) Value added in v0.0.2

func (m AnyMap) Value() (value driver.Value, err error)

type Db

type Db interface {
	// NewModelTx creates new ModelTx object
	NewModelTx() ModelTx
	// NewTx creates Tx object
	NewTx() Tx
}

Db interface exposes

func NewDb

func NewDb(driverName, dataSourceName string) Db

NewDb creates new db object

type Index added in v0.0.2

type Index struct {
	ID        string    `db:"id"`
	Format    string    `db:"format"`
	Tags      AnyMap    `db:"tags"`
	CreatedAt time.Time `db:"created_at"`
}

type IndexRecord added in v0.0.2

type IndexRecord struct {
	ID      string `db:"id"`
	IndexID string `db:"index_id"`
	Segment string `db:"segment"`
	Vector  AnyMap `db:"vector"`
}

type ModelTx

type ModelTx interface {
	Tx

	// CreateIndex creates index entry
	CreateIndex(index Index) (string, error)

	// CreateIndexRecord creates index record entry
	CreateIndexRecord(record IndexRecord) (string, error)
}

ModelTx provides a transaction with some methods for accessing to the Model objects

type QueryResult

type QueryResult[T any] struct {
	Items []T
	Total int64
}

type SqlTestSuite

type SqlTestSuite struct {
	Dir string
	suite.Suite
	// contains filtered or unexported fields
}

SqlTestSuite struct used to wrap all related database connection stuff into one suite

func (*SqlTestSuite) AfterTest

func (s *SqlTestSuite) AfterTest(suiteName, testName string)

func (*SqlTestSuite) BeforeTest

func (s *SqlTestSuite) BeforeTest(suiteName, testName string)

func (*SqlTestSuite) GetDb

func (s *SqlTestSuite) GetDb() Db

func (*SqlTestSuite) SetupSuite

func (s *SqlTestSuite) SetupSuite()

func (*SqlTestSuite) TearDownSuite

func (s *SqlTestSuite) TearDownSuite()

type Tx

type Tx interface {
	// MustBegin starts the transaction
	MustBegin()
	// MustBeginSerializable starts new transaction with Serializable isolation level
	MustBeginSerializable(ctx context.Context)
	// Commit commits the changes made within the transaction
	Commit() error
	// Rollback rolls the transaction back
	Rollback() error
	// ExecScript allows to execute the sql statements from the file provided
	ExecScript(sqlScript string) error
}

Tx interface describes an abstract DB transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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