otira

package module
v0.0.0-...-be01f37 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

README

otira

Documentation

Index

Constants

View Source
const AND = "AND"
View Source
const COMMA = ","
View Source
const COUNT = "COUNT"
View Source
const CREATE_TABLE = "CREATE TABLE"
View Source
const EQUALS = "="
View Source
const FROM = "FROM"
View Source
const INSERT = "INSERT INTO "
View Source
const PRIMARY_KEY = "PRIMARY KEY"
View Source
const SELECT = "SELECT"
View Source
const SET = "SET"
View Source
const SPC = " "
View Source
const STRING_ERROR = " -ERROR- "
View Source
const UPDATE = "UPDATE"
View Source
const UnassignedPK = -99
View Source
const VALUES = "VALUES"
View Source
const WHERE = "WHERE"

Variables

This section is empty.

Functions

func NewJoinCache

func NewJoinCache() *joinCache

Types

type DBOptions

type DBOptions struct {
	Opts         *sql.TxOptions
	Dialect      Dialect
	TxSize       int
	ChannelSize  int
	CreateTables bool
}

type Dialect

type Dialect interface {
	Constraints(FieldDef, bool) (string, error)
	CreateIndexString(string, string, []string) (string, error)
	CreateTableString(t *TableDef) (string, error)
	DropTableIfExistsString(tableName string) (string, error)
	ExistsDeepString(*Record) (string, error)
	ExistsString(table, field string, id int64) (string, error)
	FieldType(FieldDef) (string, error)
	ForeignKeys(t *TableDef) (string, error)

	IsUniqueContraintFailedError(error) bool
	Pragmas() []string
	PreparedValueFormat(counter int) (string, error)
	UpdateString(*Record) (string, error)

	NumAllowedActiveTransactions() int
	OneTransactionPerConnection() bool
}

func NewDialectSqlite3

func NewDialectSqlite3(pragmas []string, overwriteDefaultPragmas bool) Dialect

type DialectMysql

type DialectMysql struct {
}

func (*DialectMysql) CreateTableString

func (d *DialectMysql) CreateTableString(t *TableDef) string

func (*DialectMysql) NumAllowedActiveTransactions

func (d *DialectMysql) NumAllowedActiveTransactions() int

func (*DialectMysql) OneTransactionPerConnection

func (d *DialectMysql) OneTransactionPerConnection() bool

func (*DialectMysql) PreparedValueFormat

func (d *DialectMysql) PreparedValueFormat(counter int) string

type DialectOracle

type DialectOracle struct {
}

func (*DialectOracle) CreateTableString

func (d *DialectOracle) CreateTableString(t *TableDef) string

func (*DialectOracle) PreparedValueFormat

func (d *DialectOracle) PreparedValueFormat(counter int) string

type DialectPostgresql

type DialectPostgresql struct {
}

func (*DialectPostgresql) Constraints

func (d *DialectPostgresql) Constraints(fm FieldDef, primaryKey bool) (string, error)

func (*DialectPostgresql) CreateIndexString

func (d *DialectPostgresql) CreateIndexString(name string, tableName string, fieldNames []string) (string, error)

func (*DialectPostgresql) CreateTableString

func (d *DialectPostgresql) CreateTableString(t *TableDef) (string, error)

func (*DialectPostgresql) DropTableIfExistsString

func (d *DialectPostgresql) DropTableIfExistsString(tableName string) (string, error)

TODO

func (*DialectPostgresql) ExistsDeepString

func (d *DialectPostgresql) ExistsDeepString(*Record) (string, error)

func (*DialectPostgresql) ExistsString

func (d *DialectPostgresql) ExistsString(table, field string, id int64) (string, error)

func (*DialectPostgresql) FieldType

func (d *DialectPostgresql) FieldType(fm FieldDef) (string, error)

func (*DialectPostgresql) ForeignKeys

func (d *DialectPostgresql) ForeignKeys(t *TableDef) (string, error)

func (*DialectPostgresql) IsUniqueContraintFailedError

func (d *DialectPostgresql) IsUniqueContraintFailedError(err error) bool

func (*DialectPostgresql) NumAllowedActiveTransactions

func (d *DialectPostgresql) NumAllowedActiveTransactions() int

func (*DialectPostgresql) OneTransactionPerConnection

func (d *DialectPostgresql) OneTransactionPerConnection() bool

func (*DialectPostgresql) Pragmas

func (d *DialectPostgresql) Pragmas() []string

TODO

func (*DialectPostgresql) PreparedValueFormat

func (d *DialectPostgresql) PreparedValueFormat(counter int) (string, error)

func (*DialectPostgresql) UpdateString

func (d *DialectPostgresql) UpdateString(rec *Record) (string, error)

type DialectSqlite3

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

func (*DialectSqlite3) Constraints

func (d *DialectSqlite3) Constraints(fm FieldDef, primaryKey bool) (string, error)

func (*DialectSqlite3) CreateIndexString

func (d *DialectSqlite3) CreateIndexString(name string, tableName string, fieldNames []string) (string, error)

func (*DialectSqlite3) CreateTableString

func (d *DialectSqlite3) CreateTableString(t *TableDef) (string, error)

func (*DialectSqlite3) DropTableIfExistsString

func (d *DialectSqlite3) DropTableIfExistsString(tableName string) (string, error)

func (*DialectSqlite3) ExistsDeepString

func (d *DialectSqlite3) ExistsDeepString(r *Record) (string, error)

func (*DialectSqlite3) ExistsString

func (d *DialectSqlite3) ExistsString(table, field string, id int64) (string, error)

func (*DialectSqlite3) FieldType

func (d *DialectSqlite3) FieldType(fm FieldDef) (string, error)

func (*DialectSqlite3) ForeignKeys

func (d *DialectSqlite3) ForeignKeys(t *TableDef) (string, error)

func (*DialectSqlite3) IsUniqueContraintFailedError

func (d *DialectSqlite3) IsUniqueContraintFailedError(err error) bool

func (*DialectSqlite3) NumAllowedActiveTransactions

func (d *DialectSqlite3) NumAllowedActiveTransactions() int

func (*DialectSqlite3) OneTransactionPerConnection

func (d *DialectSqlite3) OneTransactionPerConnection() bool

func (*DialectSqlite3) Pragmas

func (d *DialectSqlite3) Pragmas() []string

func (*DialectSqlite3) PreparedValueFormat

func (d *DialectSqlite3) PreparedValueFormat(counter int) (string, error)

func (*DialectSqlite3) UpdateString

func (d *DialectSqlite3) UpdateString(rec *Record) (string, error)

type Director

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

func NewDirector

func NewDirector(db *sql.DB, dialect Dialect, size int) (*Director, error)

func (*Director) Done

func (dir *Director) Done() error

func (*Director) Save

func (dir *Director) Save(record *Record) error

Saves record and associated relations records

type Field

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

func (*Field) SetValue

func (f *Field) SetValue(v interface{}) error

func (*Field) SetValueFast

func (f *Field) SetValueFast(v interface{})

type FieldDef

type FieldDef interface {
	Name() string
	SetName(string)
	Table() *TableDef
	SetTable(*TableDef)
	SetLength(int)
	Length() int
	Unique() bool
	SetUnique(bool)
	Indexed() bool
	SetIndexed(bool)
	Nullable() bool
	SetNullable(bool)
	//PrimaryKey() bool
	//SetPrimaryKey(bool)
	String() string
	SetFixed(bool)
	Fixed() bool
	//Table(*Table)
	IsSameType(interface{}) bool
}

type FieldDefBool

type FieldDefBool struct {
	FieldDefImpl
}

func (*FieldDefBool) IsSameType

func (fm *FieldDefBool) IsSameType(v interface{}) bool

type FieldDefByte

type FieldDefByte struct {
	FieldDefImpl
}

func (*FieldDefByte) IsSameType

func (fm *FieldDefByte) IsSameType(v interface{}) bool

type FieldDefFloat

type FieldDefFloat struct {
	FieldDefImpl
}

func (*FieldDefFloat) IsSameType

func (fm *FieldDefFloat) IsSameType(v interface{}) bool

type FieldDefImpl

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

func (*FieldDefImpl) Fixed

func (b *FieldDefImpl) Fixed() bool

func (*FieldDefImpl) Indexed

func (b *FieldDefImpl) Indexed() bool

func (*FieldDefImpl) Length

func (b *FieldDefImpl) Length() int

func (*FieldDefImpl) Name

func (b *FieldDefImpl) Name() string

func (*FieldDefImpl) Nullable

func (b *FieldDefImpl) Nullable() bool

func (*FieldDefImpl) SetFixed

func (b *FieldDefImpl) SetFixed(v bool)

func (*FieldDefImpl) SetIndexed

func (b *FieldDefImpl) SetIndexed(v bool)

func (*FieldDefImpl) SetLength

func (b *FieldDefImpl) SetLength(n int)

func (*FieldDefImpl) SetName

func (b *FieldDefImpl) SetName(n string)

func (*FieldDefImpl) SetNullable

func (b *FieldDefImpl) SetNullable(v bool)

func (*FieldDefImpl) SetTable

func (b *FieldDefImpl) SetTable(table *TableDef)

func (*FieldDefImpl) SetUnique

func (b *FieldDefImpl) SetUnique(v bool)

func (*FieldDefImpl) String

func (b *FieldDefImpl) String() string

func (*FieldDefImpl) Table

func (b *FieldDefImpl) Table() *TableDef

func (*FieldDefImpl) Unique

func (b *FieldDefImpl) Unique() bool

type FieldDefInt

type FieldDefInt struct {
	FieldDefImpl
}

func (*FieldDefInt) IsSameType

func (fm *FieldDefInt) IsSameType(v interface{}) bool

type FieldDefInt64

type FieldDefInt64 struct {
	FieldDefImpl
}

func (*FieldDefInt64) IsSameType

func (fm *FieldDefInt64) IsSameType(v interface{}) bool

type FieldDefString

type FieldDefString struct {
	FieldDefImpl
}

////////////////////////////////////////////////////

func (*FieldDefString) IsSameType

func (fm *FieldDefString) IsSameType(v interface{}) bool

type FieldDefTime

type FieldDefTime struct {
	FieldDefImpl
}

func (*FieldDefTime) IsSameType

func (fm *FieldDefTime) IsSameType(v interface{}) bool

type FieldMeta

type FieldMeta interface {
	Name() string
	SetName(string)
	Table() *TableDef
	SetTable(*TableDef)
	SetLength(int)
	Length() int
	Unique() bool
	SetUnique(bool)
	Indexed() bool
	SetIndexed(bool)
	Nullable() bool
	SetNullable(bool)
	//PrimaryKey() bool
	//SetPrimaryKey(bool)
	String() string
	SetFixed(bool)
	Fixed() bool
	//Table(*Table)
	IsSameType(interface{}) bool
}

type FieldMetaBool

type FieldMetaBool struct {
	FieldMetaImpl
}

func (*FieldMetaBool) IsSameType

func (fm *FieldMetaBool) IsSameType(v interface{}) bool

type FieldMetaByte

type FieldMetaByte struct {
	FieldMetaImpl
}

func (*FieldMetaByte) IsSameType

func (fm *FieldMetaByte) IsSameType(v interface{}) bool

type FieldMetaFloat

type FieldMetaFloat struct {
	FieldMetaImpl
}

func (*FieldMetaFloat) IsSameType

func (fm *FieldMetaFloat) IsSameType(v interface{}) bool

type FieldMetaImpl

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

func (*FieldMetaImpl) Fixed

func (b *FieldMetaImpl) Fixed() bool

func (*FieldMetaImpl) Indexed

func (b *FieldMetaImpl) Indexed() bool

func (*FieldMetaImpl) Length

func (b *FieldMetaImpl) Length() int

func (*FieldMetaImpl) Name

func (b *FieldMetaImpl) Name() string

func (*FieldMetaImpl) Nullable

func (b *FieldMetaImpl) Nullable() bool

func (*FieldMetaImpl) SetFixed

func (b *FieldMetaImpl) SetFixed(v bool)

func (*FieldMetaImpl) SetIndexed

func (b *FieldMetaImpl) SetIndexed(v bool)

func (*FieldMetaImpl) SetLength

func (b *FieldMetaImpl) SetLength(n int)

func (*FieldMetaImpl) SetName

func (b *FieldMetaImpl) SetName(n string)

func (*FieldMetaImpl) SetNullable

func (b *FieldMetaImpl) SetNullable(v bool)

func (*FieldMetaImpl) SetTable

func (b *FieldMetaImpl) SetTable(table *TableDef)

func (*FieldMetaImpl) SetUnique

func (b *FieldMetaImpl) SetUnique(v bool)

func (*FieldMetaImpl) String

func (b *FieldMetaImpl) String() string

func (*FieldMetaImpl) Table

func (b *FieldMetaImpl) Table() *TableDef

func (*FieldMetaImpl) Unique

func (b *FieldMetaImpl) Unique() bool

type FieldMetaInt

type FieldMetaInt struct {
	FieldMetaImpl
}

func (*FieldMetaInt) IsSameType

func (fm *FieldMetaInt) IsSameType(v interface{}) bool

type FieldMetaString

type FieldMetaString struct {
	FieldMetaImpl
}

////////////////////////////////////////////////////

func (*FieldMetaString) IsSameType

func (fm *FieldMetaString) IsSameType(v interface{}) bool

type FieldMetaTime

type FieldMetaTime struct {
	FieldMetaImpl
}

func (*FieldMetaTime) IsSameType

func (fm *FieldMetaTime) IsSameType(v interface{}) bool

type FieldMetaUint64

type FieldMetaUint64 struct {
	FieldMetaImpl
}

func (*FieldMetaUint64) IsSameType

func (fm *FieldMetaUint64) IsSameType(v interface{}) bool

type ICounter

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

func (*ICounter) Next

func (c *ICounter) Next() int64

type Index

type Index struct {
	Unique bool
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(name string, fields ...*FieldDef) (*Index, error)

type ManyToMany

type ManyToMany struct {
	JoinTable *TableDef
	// contains filtered or unexported fields
}

func NewManyToMany

func NewManyToMany() *ManyToMany

func (*ManyToMany) Name

func (rel *ManyToMany) Name() string

func (*ManyToMany) String

func (mtm *ManyToMany) String() string

type OneToMany

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

func NewOneToMany

func NewOneToMany() *OneToMany

func (*OneToMany) Name

func (rel *OneToMany) Name() string

func (*OneToMany) String

func (otm *OneToMany) String() string

type Persister

type Persister struct {
	TransactionSize int

	SupportUpdates bool
	// contains filtered or unexported fields
}

func NewPersister

func NewPersister(db *sql.DB, dialect Dialect, txSize int) (*Persister, error)

needs to also have func NewPersister(ctx context.Context, db *sql.DB, dialect Dialect, size int) (*Persister, error) {

func (*Persister) BeginTx

func (pers *Persister) BeginTx() error

func (*Persister) CreatePreparedStatementInsertAllFields

func (pers *Persister) CreatePreparedStatementInsertAllFields(record *Record) (string, error)

func (*Persister) CreatePreparedStatementInsertFromRecord

func (pers *Persister) CreatePreparedStatementInsertFromRecord(record *Record) (string, error)

func (*Persister) CreatePreparedStatementInsertSomeFields

func (pers *Persister) CreatePreparedStatementInsertSomeFields(tablename string, fields ...FieldDef) (string, error)

func (*Persister) CreateTables

func (pers *Persister) CreateTables(tms ...*TableDef) error

func (*Persister) DeleteTables

func (pers *Persister) DeleteTables(tms ...*TableDef) error

func (*Persister) Done

func (pers *Persister) Done() error

func (*Persister) Exists

func (pers *Persister) Exists(r *Record) (bool, error)

func (*Persister) Save

func (pers *Persister) Save(rec *Record) error

saves record and all related records

func (*Persister) Update

func (pers *Persister) Update(rec *Record) error

type Record

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

func (*Record) AddRelationRecord

func (r *Record) AddRelationRecord(rel Relation, record *Record) error

func (*Record) Clone

func (r *Record) Clone() (*Record, error)

func (*Record) PrimaryKeyValue

func (r *Record) PrimaryKeyValue() (int64, error)

func (*Record) Reset

func (r *Record) Reset() error

func (*Record) Set

func (r *Record) Set(i int, v interface{}) error

func (*Record) SetByName

func (r *Record) SetByName(f string, v interface{}) error

func (*Record) String

func (r *Record) String() string

func (*Record) Values

func (r *Record) Values() []interface{}

type Relation

type Relation interface {
	Name() string
}

type RelationRecord

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

type Set

type Set interface {
	Put(key int64) error
	Contains(key int64) (bool, error)
	Close() error
}

func NewBadgerSet

func NewBadgerSet(dir string) (Set, error)

func NewSqlite3Set

func NewSqlite3Set(dir string) (Set, error)

type SimpleStorer

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

func (*SimpleStorer) Close

func (st *SimpleStorer) Close() error

func (*SimpleStorer) Initialize

func (st *SimpleStorer) Initialize(db *sql.DB, dbopts *DBOptions, tms ...*TableDef) error

func (*SimpleStorer) Save

func (st *SimpleStorer) Save(rec *Record) error

type Storer

type Storer interface {
	Initialize(db *sql.DB, dbopts *DBOptions, tms ...*TableDef) error
	Save(*Record) error
	Close() error
}

type TableDef

type TableDef struct {
	ICounter
	UseRecordPrimaryKeys bool
	// contains filtered or unexported fields
}

Assumes 0th field is primary key, type FieldDefInt64

func NewTableDef

func NewTableDef(name string) (*TableDef, error)

func (*TableDef) Add

func (t *TableDef) Add(f FieldDef) error

func (*TableDef) AddIndex

func (t *TableDef) AddIndex(name string, fields ...*FieldDef) error

func (*TableDef) AddManyToMany

func (t *TableDef) AddManyToMany(m2m *ManyToMany)

func (*TableDef) AddOneToMany

func (t *TableDef) AddOneToMany(one2m *OneToMany)

func (*TableDef) AddOneToMany_OLD

func (t *TableDef) AddOneToMany_OLD(rel *OneToMany) error

func (*TableDef) CreatePreparedStatementInsertAllFields

func (t *TableDef) CreatePreparedStatementInsertAllFields(dialect Dialect) (string, error)

func (*TableDef) CreatePreparedStatementInsertFromRecord

func (t *TableDef) CreatePreparedStatementInsertFromRecord(dialect Dialect, record *Record) (string, error)

func (*TableDef) CreatePreparedStatementInsertSomeFields

func (t *TableDef) CreatePreparedStatementInsertSomeFields(dialect Dialect, fields ...FieldDef) (string, error)

func (*TableDef) Done

func (t *TableDef) Done() bool

func (*TableDef) Fields

func (t *TableDef) Fields() []FieldDef

func (*TableDef) GetField

func (t *TableDef) GetField(s string) FieldDef

func (*TableDef) GetOneToMany

func (t *TableDef) GetOneToMany(k string) *OneToMany

func (*TableDef) Name

func (t *TableDef) Name() string

func (*TableDef) NewRecord

func (t *TableDef) NewRecord() (*Record, error)

func (*TableDef) NewRecordSomeFields

func (t *TableDef) NewRecordSomeFields(fields ...FieldDef) (*Record, error)

func (*TableDef) PrimaryKey

func (t *TableDef) PrimaryKey() FieldDef

func (*TableDef) SetDone

func (t *TableDef) SetDone() error

func (*TableDef) SetJoinDiscrimFields

func (t *TableDef) SetJoinDiscrimFields(fields ...FieldDef)

type TransactionHandler

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

func NewTransactionHandler

func NewTransactionHandler(c chan []*Record, conn *sql.Conn, ctx *context.Context, opts *sql.TxOptions, dialect *Dialect, txSize int) (*TransactionHandler, error)

Jump to

Keyboard shortcuts

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