store

package
v1.6.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database represents a destination or source database of query.

func NewDatabase

func NewDatabase() *Database

NewDatabase returns a new database.

func NewDatabaseWithName

func NewDatabaseWithName(name string) *Database

NewDatabaseWithName returns a new database with the specified string.

func (*Database) AddTable

func (db *Database) AddTable(table *Table)

AddTable adds a specified table into the database.

func (*Database) AddTables

func (db *Database) AddTables(tables []*Table)

AddTables adds a specified tables into the database.

func (*Database) DropTable

func (db *Database) DropTable(table *Table) bool

DropTable remove the specified table.

func (*Database) LookupTable added in v1.5.7

func (db *Database) LookupTable(name string) (*Table, bool)

LookupTable returns a table with the specified name.

func (*Database) Name

func (db *Database) Name() string

Name returns the database name.

func (*Database) Tables

func (db *Database) Tables() []*Table

Tables returns all tables in the database.

type Databases

type Databases map[string]*Database

Databases represents a collection of databases.

func NewDatabases

func NewDatabases() Databases

NewDatabases returns a databases instance.

func (Databases) AddDatabase

func (dbs Databases) AddDatabase(db *Database) error

AddDatabase adds a specified database.

func (Databases) DropDatabase

func (dbs Databases) DropDatabase(db *Database) error

DropDatabase remove the specified database.

func (Databases) LookupDatabase added in v1.5.7

func (dbs Databases) LookupDatabase(name string) (*Database, bool)

LookupDatabase returns a database with the specified name.

func (*Databases) LookupTableWithDatabase added in v1.5.7

func (dbs *Databases) LookupTableWithDatabase(dbName string, tableName string) (*Table, bool)

LookupTableWithDatabase returns a specified table in a specified database.

type Row

type Row map[string]any

Row represents a row of a table.

func NewRow

func NewRow() Row

NewRow returns a new row.

func NewRowWith

func NewRowWith(table *Table, cols query.Columns) Row

NewRowWith returns a new row with the specified columns.

func (Row) IsEqual

func (row Row) IsEqual(other Row) bool

IsEqual returns true if the row is equal to the specified row.

func (Row) IsMatched

func (row Row) IsMatched(cond query.Condition) bool

IsMatched returns true if the row is matched with the specified condition.

func (Row) Update

func (row Row) Update(colums []query.Column)

Update updates the row with the specified columns.

func (Row) ValueByName

func (row Row) ValueByName(name string) (any, error)

ValueByName returns a value of the specified column name.

type Store added in v1.6.0

type Store struct {
	Databases
}

Store represents a data store.

func NewStore added in v1.6.0

func NewStore() *Store

NewStore returns a new store instance.

func (*Store) AlterDatabase added in v1.6.0

func (store *Store) AlterDatabase(conn net.Conn, stmt query.AlterDatabase) error

AlterDatabase should handle a ALTER database statement.

func (*Store) AlterTable added in v1.6.0

func (store *Store) AlterTable(conn net.Conn, stmt query.AlterTable) error

AlterTable should handle a ALTER table statement.

func (*Store) Begin added in v1.6.0

func (store *Store) Begin(conn net.Conn, stmt query.Begin) error

Begin should handle a BEGIN statement.

func (*Store) Commit added in v1.6.0

func (store *Store) Commit(conn net.Conn, stmt query.Commit) error

Commit should handle a COMMIT statement.

func (*Store) CreateDatabase added in v1.6.0

func (store *Store) CreateDatabase(conn net.Conn, stmt query.CreateDatabase) error

CreateDatabase should handle a CREATE database statement.

func (*Store) CreateTable added in v1.6.0

func (store *Store) CreateTable(conn net.Conn, stmt query.CreateTable) error

CreateTable should handle a CREATE table statement.

func (*Store) Delete added in v1.6.0

func (store *Store) Delete(conn net.Conn, stmt query.Delete) (sql.ResultSet, error)

Delete should handle a DELETE statement.

func (*Store) DropDatabase added in v1.6.0

func (store *Store) DropDatabase(conn net.Conn, stmt query.DropDatabase) error

DropDatabase should handle a DROP database statement.

func (*Store) DropTable added in v1.6.0

func (store *Store) DropTable(conn net.Conn, stmt query.DropTable) error

DropTable should handle a DROP table statement.

func (*Store) Insert added in v1.6.0

func (store *Store) Insert(conn net.Conn, stmt query.Insert) error

Insert should handle a INSERT statement.

func (*Store) LookupDatabaseTable added in v1.6.0

func (store *Store) LookupDatabaseTable(conn net.Conn, dbName string, tblName string) (*Database, *Table, error)

func (*Store) Rollback added in v1.6.0

func (store *Store) Rollback(conn net.Conn, stmt query.Rollback) error

Rollback should handle a ROLLBACK statement.

func (*Store) Select added in v1.6.0

func (store *Store) Select(conn net.Conn, stmt query.Select) (sql.ResultSet, error)

Select should handle a SELECT statement.

func (*Store) SystemSelect added in v1.6.0

func (store *Store) SystemSelect(conn net.Conn, stmt query.Select) (sql.ResultSet, error)

SystemSelect should handle a system SELECT statement.

func (*Store) Update added in v1.6.0

func (store *Store) Update(conn net.Conn, stmt query.Update) (sql.ResultSet, error)

Update should handle a UPDATE statement.

func (*Store) Use added in v1.6.0

func (store *Store) Use(conn net.Conn, stmt query.Use) error

Use should handle a USE statement.

type Table

type Table struct {
	sync.Mutex
	Name string
	query.Schema
	Rows []Row
}

Table represents a destination or source database of query.

func NewTableWith

func NewTableWith(name string, schema query.Schema) *Table

NewTable returns a new table.

func (*Table) Delete

func (tbl *Table) Delete(cond query.Condition) (int, error)

Delete deletes rows matched to the specified condition.

func (*Table) Insert

func (tbl *Table) Insert(cols []query.Column) error

Insert inserts a new row.

func (*Table) Select

func (tbl *Table) Select(cond query.Condition) ([]Row, error)

Select returns rows matched to the specified condition.

func (*Table) Update

func (tbl *Table) Update(cols []query.Column, cond query.Condition) (int, error)

Update updates rows matched to the specified condition.

Jump to

Keyboard shortcuts

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