Documentation ¶
Index ¶
- Constants
- func Connect(connURL, driver string) (*sqlx.DB, error)
- func CreateModel[T any](m *T) error
- func DeleteModel[T any](m *T) error
- func GetModel[T any](m *T, field string, value any, filters ...Filter) error
- func ListModels[T any](page, limit int, field string, value any, filters ...Filter) ([]*T, int, error)
- func Load()
- func Register(driver IDatabase)
- func UpdateModel[T any](m *T) error
- type Column
- type DB
- type DBModel
- func (db *DBModel) Begin() *DBModel
- func (db *DBModel) Commit() error
- func (db *DBModel) Create(model any) (err error)
- func (db *DBModel) Delete(model any, args ...any) (err error)
- func (db *DBModel) Fetch(offset, fetch int) *DBModel
- func (db *DBModel) Find(model any, params ...any) (total int, err error)
- func (db *DBModel) First(model any) (err error)
- func (db *DBModel) Get(model any, getType GetOne) (err error)
- func (db *DBModel) GroupBy(fields ...string) *DBModel
- func (db *DBModel) Having(field any, opt fluentsql.WhereOpt, value any) *DBModel
- func (db *DBModel) Join(join fluentsql.JoinType, table string, condition fluentsql.Condition) *DBModel
- func (db *DBModel) Last(model any) (err error)
- func (db *DBModel) Limit(limit, offset int) *DBModel
- func (db *DBModel) Model(model any) *DBModel
- func (db *DBModel) Omit(columns ...any) *DBModel
- func (db *DBModel) OrderBy(field string, dir fluentsql.OrderByDir) *DBModel
- func (db *DBModel) Raw(sqlStr string, args ...any) *DBModel
- func (db *DBModel) RemoveFetch() fluentsql.Fetch
- func (db *DBModel) RemoveLimit() fluentsql.Limit
- func (db *DBModel) Rollback() error
- func (db *DBModel) Select(columns ...any) *DBModel
- func (db *DBModel) Take(model any, args ...any) (err error)
- func (db *DBModel) Update(model any) (err error)
- func (db *DBModel) When(condition bool, groupCondition fluentsql.FnWhereBuilder) *DBModel
- func (db *DBModel) Where(field any, opt fluentsql.WhereOpt, value any) *DBModel
- func (db *DBModel) WhereGroup(groupCondition fluentsql.FnWhereBuilder) *DBModel
- func (db *DBModel) WhereOr(field any, opt fluentsql.WhereOpt, value any) *DBModel
- type Filter
- type GetOne
- type IDatabase
- type MetaData
- type Raw
- type Table
Constants ¶
View Source
const ( MODEL = "model" // Tag `model` TABLE = "table" // Table name TYPE = "type" // Column types REFERENCE = "ref" // Column reference CASCADE = "cascade" // Column cascade DELETE, UPDATE RELATION = "rel" // Column relationship NAME = "name" // Column name )
Variables ¶
This section is empty.
Functions ¶
func CreateModel ¶
CreateModel a query that creating a model by given model's data
func DeleteModel ¶
DeleteModel a query that deleting a model by given model data.
func GetModel ¶
GetModel takes a model, query field, and condition value. query for getting one model by a specific field condition
func ListModels ¶
func ListModels[T any](page, limit int, field string, value any, filters ...Filter) ([]*T, int, error)
ListModels is a query that returns slice of models, paginate by limit and offset
func Register ¶
func Register(driver IDatabase)
Register assign DB provider type fluentsql.PostgreSQL, fluentsql.MySQL,...
func UpdateModel ¶
UpdateModel a query that updating a model by given model's data
Types ¶
type Column ¶
type Column struct { Key string Name string Primary bool Types string Ref string // Reference id to table Relation string // Relation to table IsZero bool // Keep Zero value of type HasValue bool }
Column structure
type DBModel ¶
type DBModel struct {
// contains filtered or unexported fields
}
func (*DBModel) Join ¶
func (db *DBModel) Join(join fluentsql.JoinType, table string, condition fluentsql.Condition) *DBModel
Join builder
func (*DBModel) OrderBy ¶
func (db *DBModel) OrderBy(field string, dir fluentsql.OrderByDir) *DBModel
OrderBy builder
func (*DBModel) When ¶
func (db *DBModel) When(condition bool, groupCondition fluentsql.FnWhereBuilder) *DBModel
When checking TRUE to build Where condition.
func (*DBModel) WhereGroup ¶
func (db *DBModel) WhereGroup(groupCondition fluentsql.FnWhereBuilder) *DBModel
WhereGroup combine multi where conditions into a group.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.