Documentation ¶
Index ¶
- Constants
- type Dialect
- type DialectSqlite3
- func (d *DialectSqlite3) CreateTableSql(table string, fields []*Field, pk string) (string, error)
- func (d *DialectSqlite3) DeleteByPKPreparedStatementSql(table string, pk string, needsQuotes bool) (string, error)
- func (t *DialectSqlite3) GetEnforceForeignKeys() bool
- func (t *DialectSqlite3) GetPragmas() []string
- func (d *DialectSqlite3) InsertPreparedStatementSql(table string, fields []*Field) (string, error)
- func (d *DialectSqlite3) OpenDB(dataSourceName string) (*sql.DB, error)
- func (d *DialectSqlite3) SelectOneRecordByPKPreparedStatementSql(table string, fields []*Field, pk string, needsQuotes bool) (string, error)
- func (t *DialectSqlite3) SetEnforceForeignKeys(enforceForeignKeys bool)
- func (t *DialectSqlite3) SetPragmas(pragmas []string)
- type Field
- type JoinTableInfo
- type PTable
- type Persister
- func (p *Persister) CreateTables(tables ...*Table) error
- func (p *Persister) DeleteByPK(tab *Table, v any) error
- func (p *Persister) ExistsByPK(tab *Table, v any) (bool, error)
- func (p *Persister) Insert(rec *Record) error
- func (p *Persister) InsertJoin(jt *Table, leftRec, rightRec *Record) error
- func (p *Persister) JoinTableInsert(joinTable *Table, leftRec, rightRec *Record) error
- func (p *Persister) SelectOneRecordByPK(tab *Table, v any, rec *Record) error
- func (p *Persister) TxBegin(tables ...*Table) error
- func (p *Persister) TxCommit(tables ...*Table) error
- type Record
- type SqlType
- type Table
Constants ¶
View Source
const SEPARATOR = "|"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect interface { InsertPreparedStatementSql(table string, fields []*Field) (string, error) DeleteByPKPreparedStatementSql(table string, pk string, needsQuotes bool) (string, error) SelectOneRecordByPKPreparedStatementSql(table string, fields []*Field, pk string, needsQuotes bool) (string, error) CreateTableSql(table string, fields []*Field, pk string) (string, error) SetEnforceForeignKeys(bool) GetEnforceForeignKeys() bool SetPragmas([]string) GetPragmas() []string OpenDB(dataSourceName string) (*sql.DB, error) }
borrowed from otira https://github.com/gnewton/otira/blob/master/dialect.go
func NewDialectSqlite3 ¶
type DialectSqlite3 ¶
type DialectSqlite3 struct {
// contains filtered or unexported fields
}
func (*DialectSqlite3) CreateTableSql ¶
func (*DialectSqlite3) DeleteByPKPreparedStatementSql ¶
func (*DialectSqlite3) GetEnforceForeignKeys ¶
func (t *DialectSqlite3) GetEnforceForeignKeys() bool
func (*DialectSqlite3) GetPragmas ¶
func (t *DialectSqlite3) GetPragmas() []string
func (*DialectSqlite3) InsertPreparedStatementSql ¶
func (d *DialectSqlite3) InsertPreparedStatementSql(table string, fields []*Field) (string, error)
func (*DialectSqlite3) OpenDB ¶
func (d *DialectSqlite3) OpenDB(dataSourceName string) (*sql.DB, error)
func (*DialectSqlite3) SelectOneRecordByPKPreparedStatementSql ¶
func (*DialectSqlite3) SetEnforceForeignKeys ¶
func (t *DialectSqlite3) SetEnforceForeignKeys(enforceForeignKeys bool)
func (*DialectSqlite3) SetPragmas ¶
func (t *DialectSqlite3) SetPragmas(pragmas []string)
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (*Field) CheckValueType ¶
func (*Field) NeedsQuotes ¶
type JoinTableInfo ¶
type JoinTableInfo struct {
// contains filtered or unexported fields
}
type Persister ¶
type Persister struct {
// contains filtered or unexported fields
}
func NewPersister ¶
func (*Persister) CreateTables ¶
func (*Persister) InsertJoin ¶
Responsible to: 1 - If Right table id is not in cache (not previously saved; key is )
- Increment right table id counter, add it to cache; assign to right table rec,
- Assign right table rec PK = right table id counter
- Save right table rec
2 - Assign jt rt id = right table id counter 3 - Save jt
func (*Persister) JoinTableInsert ¶
func (*Persister) SelectOneRecordByPK ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func NewJoinTable ¶
func NewJoinTable(leftTable, rightTable *Table, additionalFields []*Field, rightTableIDCacheKeyFields ...*Field) (*Table, error)
func NewJoinTable(leftTable, rightTable *Table, additionalFields []*Field, rightTableIDCacheKeyFields ...*Field) (*Table, error) {
func (*Table) JoinRecords ¶
func (t *Table) JoinRecords(leftR, rightR *Record, joinTable *Table, additionalJTfields *Field) ([]*Record, error)
Returns the newly create join record and (if does not already exist) the right record (which is also passed in) Whatever records are return are to be saved
func (*Table) SetPrimaryKey ¶
Click to show internal directories.
Click to hide internal directories.