Documentation
¶
Index ¶
- Constants
- Variables
- func Close() error
- func CreateTable(model any, tablename string) error
- func Drop(model any) error
- func DropByName(tablename string) error
- func Exec(query string, params ...any) (sql.Result, error)
- func Insert(model any) error
- func InsertByName(model any, tablename string) error
- func PrintQueryHistory()
- func Query(query string, params ...any) (*sql.Rows, error)
- func QueryRow(query string, params ...any) (*sql.Row, error)
- func Read(model any, filters *Filter, tablename string) error
- func SetDefaultClient(engine ENGINE, connString string) error
- type DBInfo
- type ENGINE
- type Filter
- func (f *Filter) And(key string, c FilterComparison, val any) *Filter
- func (f *Filter) AndIsNull(key string) *Filter
- func (f *Filter) Group() *FilterGroup
- func (f *Filter) Or(key string, c FilterComparison, val any) *Filter
- func (f *Filter) OrIsNull(key string) *Filter
- func (f *Filter) WhereSQL() (string, error)
- type FilterComparison
- type FilterGroup
- func (fg *FilterGroup) And(k string, c FilterComparison, v any) *FilterGroup
- func (fg *FilterGroup) AndIsNull(key string) *FilterGroup
- func (fg *FilterGroup) Or(k string, c FilterComparison, v any) *FilterGroup
- func (fg *FilterGroup) OrIsNull(key string) *FilterGroup
- func (fg *FilterGroup) SQL() (string, error)
- type FilterItem
- type FilterSeparator
- type FnConnect
- type MORM
- func (m *MORM) Close() error
- func (m *MORM) CreateTable(model any, tablename string) error
- func (m *MORM) Delete(model any, filters *Filter) Result
- func (m *MORM) DeleteByName(tablename string, filters *Filter) Result
- func (m *MORM) Drop(model any) error
- func (m *MORM) DropByName(tablename string) error
- func (m *MORM) Exec(query string, params ...any) (sql.Result, error)
- func (m *MORM) GetDatabaseName() string
- func (m *MORM) Info() (DBInfo, error)
- func (m *MORM) Insert(model any) error
- func (m *MORM) InsertByName(model any, tablename string) error
- func (m *MORM) Query(query string, params ...any) (*sql.Rows, error)
- func (m *MORM) QueryRow(query string, params ...any) (*sql.Row, error)
- func (m *MORM) Read(model any, filters *Filter, tablename string) error
- func (m *MORM) Update(model any, filters *Filter, fields ...string) Result
- type MSSQLInfo
- type MormTag
- type Result
Constants ¶
const ( IgnoreDirective = ":ignore" FlattenDirective = ":flatten" )
Variables ¶
var ( ErrDefaultClientIsNil = errors.New("err defautl client is nil") ErrDBIsNil = errors.New("err db interface is nil") )
var ErrValIsNotExpectedType = errors.New("val is not of the expected type")
Functions ¶
func Close ¶ added in v0.3.1
func Close() error
Close closes databse connection for the default MORM client
func CreateTable ¶
CreateTable creates a new table if it does not exists, tablename is used if is not <nil> otherwise the struct name is used as the table name.
func DropByName ¶ added in v0.3.1
func InsertByName ¶
InsertByName creates a new record where the tablename is explicit not implicit
func PrintQueryHistory ¶
func PrintQueryHistory()
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func (*Filter) Group ¶
func (f *Filter) Group() *FilterGroup
type FilterComparison ¶
type FilterComparison string
const ( EQUAL FilterComparison = "=" NOT_EQUAL FilterComparison = "<>" GREATER FilterComparison = ">" GREATER_OR_EQ FilterComparison = ">=" LESS_THAN FilterComparison = "<" LESS_THAN_OR_EQ FilterComparison = "<=" IS FilterComparison = "is" )
type FilterGroup ¶
type FilterGroup struct {
// contains filtered or unexported fields
}
func (*FilterGroup) And ¶
func (fg *FilterGroup) And(k string, c FilterComparison, v any) *FilterGroup
func (*FilterGroup) AndIsNull ¶ added in v0.2.1
func (fg *FilterGroup) AndIsNull(key string) *FilterGroup
func (*FilterGroup) Or ¶
func (fg *FilterGroup) Or(k string, c FilterComparison, v any) *FilterGroup
func (*FilterGroup) OrIsNull ¶ added in v0.2.1
func (fg *FilterGroup) OrIsNull(key string) *FilterGroup
func (*FilterGroup) SQL ¶
func (fg *FilterGroup) SQL() (string, error)
type FilterItem ¶
type FilterItem struct {
// contains filtered or unexported fields
}
type FilterSeparator ¶
type FilterSeparator string
const ( AND FilterSeparator = "and" OR FilterSeparator = "or" )
type MORM ¶
type MORM struct {
// contains filtered or unexported fields
}
func GetDefault ¶ added in v0.9.3
GetDefault returns the package level MORM or an error
func GetDefaultMust ¶ added in v0.9.3
func GetDefaultMust() *MORM
GetDefaultMust returns default MORM panics on error
func NewWithName ¶ added in v0.10.3
func (*MORM) CreateTable ¶ added in v0.9.3
CreateTable creates a table base on the model and optional tablename
func (*MORM) Delete ¶ added in v0.9.3
Delete deletes a record from the table representation of the model passed in
func (*MORM) DeleteByName ¶ added in v0.9.3
DeleteByName deletes records from a tablename based on filter
func (*MORM) DropByName ¶ added in v0.9.3
func (*MORM) GetDatabaseName ¶ added in v0.10.3
GetDatabaseName returns the databasename is any
func (*MORM) InsertByName ¶ added in v0.9.3
InsertByName creates a new record where the tablename is explicit not implicit
type MSSQLInfo ¶ added in v0.10.3
type MSSQLInfo struct {
// contains filtered or unexported fields
}
func (MSSQLInfo) EngineEdition ¶ added in v0.10.3
type MormTag ¶
type MormTag struct {
// contains filtered or unexported fields
}
MormTag is a representation of the morm notation tag
func (MormTag) IsDirective ¶
IsDirective checks if the notation tag is a morm directive