linq

package
v0.0.97 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ActDelete = 5
View Source
const ActInsert = 4
View Source
const ActSelect = 3
View Source
const ActUpdate = 6
View Source
const ActUpsert = 7
View Source
const AfterDelete = 6
View Source
const AfterInsert = 2
View Source
const AfterUpdate = 4
View Source
const BeforeDelete = 5
View Source
const BeforeInsert = 1
View Source
const BeforeUpdate = 3
View Source
const TpAtrib = 1
View Source
const TpClone = 5
View Source
const TpColumn = 0
View Source
const TpData = 2
View Source
const TpDetail = 2
View Source
const TpField = 6
View Source
const TpFunction = 4
View Source
const TpReference = 3
View Source
const TpSelect = 1

Variables

This section is empty.

Functions

func DDLColumn added in v0.0.79

func DDLColumn(col *Column) string

func DDLIndex added in v0.0.79

func DDLIndex(col *Column) string

func DDLUniqueIndex added in v0.0.79

func DDLUniqueIndex(col *Column) string

func Describe

func Describe(db int, schema, model, filter string) e.Json

func FunctionDef added in v0.0.8

func FunctionDef(linq *Linq, col *Column) string

func GetAs

func GetAs(n int) string

* * *

Types

type Col

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

* * *

func (*Col) As

func (c *Col) As() string

func (*Col) AsLow

func (c *Col) AsLow() string

func (*Col) AsUp

func (c *Col) AsUp() string

func (*Col) Cast

func (c *Col) Cast(cast string) *Col

func (*Col) Low

func (c *Col) Low() string

func (*Col) Up

func (c *Col) Up() string

type Column

type Column struct {
	Model  *Model
	Tp     int
	Column *Column

	Title       string
	Description string
	Type        string
	Default     any
	Atribs      []*Column
	Reference   *Reference
	Definition  interface{}
	Function    string
	Details     Details
	Indexed     bool
	Unique      bool
	Required    bool
	RequiredMsg string
	PrimaryKey  bool
	ForeignKey  bool
	Hidden      bool
	// contains filtered or unexported fields
}

func Concat

func Concat(args ...any) *Column

func NewColumn

func NewColumn(model *Model, name, description, _type string, _default any) *Column

func NewVirtualAtrib

func NewVirtualAtrib(model *Model, name, description, _type string, _default any) *Column

func (*Column) As

func (c *Column) As(linq *Linq) string

* * This function not use in Select *

func (*Column) Cast

func (c *Column) Cast(cast string) *Column

func (*Column) ColName added in v0.0.88

func (c *Column) ColName() string

func (*Column) DDL

func (c *Column) DDL() string

* * DDL *

func (*Column) DDLIndex added in v0.0.27

func (c *Column) DDLIndex() string

func (*Column) DDLUniqueIndex added in v0.0.66

func (c *Column) DDLUniqueIndex() string

func (*Column) Def

func (c *Column) Def(linq *Linq) string

* * This function use in Select *

func (*Column) Describe

func (c *Column) Describe() e.Json

func (*Column) Driver added in v0.0.79

func (c *Column) Driver() string

func (*Column) Eq

func (c *Column) Eq(val any) *Where

* * *

func (*Column) From

func (c *Column) From(from string) *Column

* * This function use in Select *

func (*Column) In

func (c *Column) In(vals ...any) *Where

func (*Column) Less

func (c *Column) Less(val any) *Where

func (*Column) LessEq

func (c *Column) LessEq(val any) *Where

func (*Column) Like

func (c *Column) Like(val any) *Where

func (*Column) Low

func (c *Column) Low() string

func (*Column) More

func (c *Column) More(val any) *Where

func (*Column) MoreEq

func (c *Column) MoreEq(val any) *Where

func (*Column) Name

func (c *Column) Name(name string) *Column

func (*Column) Neg

func (c *Column) Neg(val any) *Where

func (*Column) Up

func (c *Column) Up() string

* * *

func (*Column) Valid added in v0.0.67

func (c *Column) Valid(val any) error

type Details

type Details func(col *Column, data *e.Json)

* * *

type FRom

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

* * *

func (*FRom) As

func (c *FRom) As() string

func (*FRom) Col

func (c *FRom) Col(name string, cast ...string) *Col

func (*FRom) Column

func (c *FRom) Column(name string, cast ...string) *Col

func (*FRom) NameAs

func (c *FRom) NameAs() string

type Join

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

* * *

type Linq

type Linq struct {
	Tp  int
	Act int
	// contains filtered or unexported fields
}

* * *

func From

func From(model *Model, as ...string) *Linq

* * *

func NewLinq

func NewLinq(act int, model *Model, as ...string) *Linq

* * *

func (*Linq) AddPrimaryKey added in v0.0.88

func (c *Linq) AddPrimaryKey(col *Column, val any)

func (*Linq) AddValidate added in v0.0.69

func (c *Linq) AddValidate(col *Column, val any)

func (*Linq) All added in v0.0.55

func (s *Linq) All() (e.Items, error)

func (*Linq) And

func (c *Linq) And(where *Where) *Linq

func (*Linq) As

func (c *Linq) As(val any) string

func (*Linq) Col

func (c *Linq) Col(val any) *Column

func (*Linq) Command

func (c *Linq) Command() (e.Items, error)

* * Executors *

func (*Linq) CommandOne added in v0.0.88

func (c *Linq) CommandOne() (e.Item, error)

func (*Linq) Count

func (s *Linq) Count() int

func (*Linq) Current

func (c *Linq) Current() (e.Items, error)

* * *

func (*Linq) Data added in v0.0.93

func (s *Linq) Data(sel ...any) *Linq

func (*Linq) Debug

func (c *Linq) Debug() *Linq

func (*Linq) Details

func (c *Linq) Details(data *e.Json) *e.Json

func (*Linq) Find

func (s *Linq) Find() (e.Items, error)

* * *

func (*Linq) First

func (s *Linq) First() (e.Item, error)

func (*Linq) From

func (c *Linq) From(model *Model, as ...string) *Linq

func (*Linq) GetAs

func (c *Linq) GetAs() string

func (*Linq) GetCol

func (c *Linq) GetCol(name string) *Column

func (*Linq) GetFrom

func (c *Linq) GetFrom(col *Column) *FRom

func (*Linq) GroupBy

func (c *Linq) GroupBy(cols ...any) *Linq

func (*Linq) Join

func (c *Linq) Join(from, join *FRom, where *Where) *Linq

func (*Linq) LeftJoin

func (c *Linq) LeftJoin(from, join *FRom, where *Where) *Linq

func (*Linq) Limit

func (s *Linq) Limit(limit int) (e.Items, error)

func (*Linq) List

func (s *Linq) List(page, rows int) (e.List, error)

func (*Linq) Or

func (c *Linq) Or(where *Where) *Linq

func (*Linq) OrderBy

func (c *Linq) OrderBy(col *Column, sorted bool) *Linq

func (*Linq) Page

func (s *Linq) Page(page, rows int) (e.Items, error)

func (*Linq) PrepareDelete

func (c *Linq) PrepareDelete() (e.Items, error)

func (*Linq) PrepareInsert

func (c *Linq) PrepareInsert() error

* * Prepare command data *

func (*Linq) PrepareUpdate

func (c *Linq) PrepareUpdate() (e.Items, error)

func (*Linq) PrepareUpsert added in v0.0.86

func (c *Linq) PrepareUpsert() (e.Items, error)

func (*Linq) Query

func (c *Linq) Query() (e.Items, error)

* * Query *

func (*Linq) QueryCount

func (c *Linq) QueryCount() int

func (*Linq) QueryOne

func (c *Linq) QueryOne() (e.Item, error)

func (*Linq) Returns

func (c *Linq) Returns(cols ...any) *Linq

func (*Linq) RightJoin

func (c *Linq) RightJoin(from, join *FRom, where *Where) *Linq

func (*Linq) SQL

func (c *Linq) SQL() SQL

func (*Linq) Select

func (s *Linq) Select(sel ...any) *Linq

func (*Linq) SetAs

func (c *Linq) SetAs(model *Model, as string) string

func (*Linq) SetFromAs

func (c *Linq) SetFromAs(from *FRom) *FRom

func (*Linq) SetTp added in v0.0.57

func (c *Linq) SetTp(tp int) *Linq

* * *

func (*Linq) Sql

func (c *Linq) Sql() string

func (*Linq) SqlAll added in v0.0.55

func (c *Linq) SqlAll() string

func (*Linq) SqlColumDef

func (c *Linq) SqlColumDef(cols ...*Column) string

* * *

func (*Linq) SqlColums

func (c *Linq) SqlColums(cols ...*Column) string

func (*Linq) SqlCount

func (c *Linq) SqlCount() string

func (*Linq) SqlCurrent

func (c *Linq) SqlCurrent() string

func (*Linq) SqlDelete

func (c *Linq) SqlDelete() string

func (*Linq) SqlFrom

func (c *Linq) SqlFrom() string

func (*Linq) SqlGroupBy

func (c *Linq) SqlGroupBy() string

func (*Linq) SqlIndex

func (c *Linq) SqlIndex() string

func (*Linq) SqlInsert

func (c *Linq) SqlInsert() string

* * *

func (*Linq) SqlJoin

func (c *Linq) SqlJoin() string

func (*Linq) SqlKeys added in v0.0.86

func (c *Linq) SqlKeys() string

func (*Linq) SqlLimit

func (c *Linq) SqlLimit(limit int) string

func (*Linq) SqlOffset

func (c *Linq) SqlOffset(limit, offset int) string

func (*Linq) SqlOrderBy

func (c *Linq) SqlOrderBy() string

func (*Linq) SqlReturn

func (c *Linq) SqlReturn() string

func (*Linq) SqlSelect

func (c *Linq) SqlSelect() string

* * *

func (*Linq) SqlUpdate

func (c *Linq) SqlUpdate() string

func (*Linq) SqlWhere

func (c *Linq) SqlWhere() string

func (*Linq) ToCols

func (c *Linq) ToCols(sel ...any) []*Column

func (*Linq) Where

func (c *Linq) Where(where *Where) *Linq

type Model

type Model struct {
	Db              int
	Database        *jdb.Db
	Name            string
	Description     string
	Schema          string
	Table           string
	Definition      []*Column
	PrimaryKeys     []string
	ForeignKey      []*Reference
	Index           []string
	SourceField     string
	DateMakeField   string
	DateUpdateField string
	IndexField      string
	CodeField       string
	ProjectField    string
	StateField      string
	Ddl             string

	UseState      bool
	UseSource     bool
	UseDateMake   bool
	UseDateUpdate bool
	UseProject    bool
	UseIndex      bool
	UseSync       bool
	UseRecycle    bool
	BeforeInsert  []Trigger
	AfterInsert   []Trigger
	BeforeUpdate  []Trigger
	AfterUpdate   []Trigger
	BeforeDelete  []Trigger
	AfterDelete   []Trigger
	Version       int
	// contains filtered or unexported fields
}

func NewModel

func NewModel(schema *Schema, table, description string, version int) *Model

* * *

func (*Model) All

func (c *Model) All() []*Column

func (*Model) As

func (c *Model) As(as string) *FRom

func (*Model) Atrib

func (c *Model) Atrib(name string) *Column

func (*Model) AtribIdx

func (c *Model) AtribIdx(name string) int

func (*Model) Avg added in v0.0.8

func (c *Model) Avg(args ...any) *Column

func (*Model) Changue

func (c *Model) Changue(current e.Json, linq *Linq) *Linq

func (*Model) Col

func (c *Model) Col(name string) *Column

func (*Model) ColIdx

func (c *Model) ColIdx(name string) int

func (*Model) Column

func (c *Model) Column(name string) *Column

func (*Model) Concat

func (c *Model) Concat(args ...any) *Column

* * *

func (*Model) Consolidate

func (c *Model) Consolidate(linq *Linq) *Linq

* * *

func (*Model) Count added in v0.0.8

func (c *Model) Count(args ...any) *Column

func (*Model) DDL

func (c *Model) DDL() string

func (*Model) DDLMigration added in v0.0.29

func (c *Model) DDLMigration() string

func (*Model) Data added in v0.0.93

func (c *Model) Data(sel ...any) *Linq

func (*Model) DefineAtrib

func (c *Model) DefineAtrib(name, description, _type string, _default any) *Model

func (*Model) DefineColum

func (c *Model) DefineColum(name, description, _type string, _default any) *Model

* * *

func (*Model) DefineField

func (c *Model) DefineField(name, description string, _default any, definition string) *Model

func (*Model) DefineForeignKey

func (c *Model) DefineForeignKey(thisKey string, otherKey *Column) *Model

func (*Model) DefineHidden

func (c *Model) DefineHidden(hiddens []string) *Model

func (*Model) DefineIndex

func (c *Model) DefineIndex(index []string) *Model

func (*Model) DefinePrimaryKey

func (c *Model) DefinePrimaryKey(keys []string) *Model

func (*Model) DefineReference

func (c *Model) DefineReference(thisKey, name, otherKey string, column *Column) *Model

func (*Model) DefineRequired added in v0.0.67

func (c *Model) DefineRequired(names []string) *Model

func (*Model) DefineUniqueIndex added in v0.0.66

func (c *Model) DefineUniqueIndex(index []string) *Model

func (*Model) Delete

func (c *Model) Delete() *Linq

func (*Model) Describe

func (c *Model) Describe() e.Json

func (*Model) Details

func (c *Model) Details(name, description string, _default any, details Details)

func (*Model) Driver added in v0.0.79

func (c *Model) Driver() string

func (*Model) DropDDL

func (c *Model) DropDDL() string

func (*Model) From

func (c *Model) From() *Linq

* * *

func (*Model) Init added in v0.0.29

func (c *Model) Init() error

* * DDL *

func (*Model) Insert

func (c *Model) Insert(data e.Json) *Linq

func (*Model) IntegrityAtrib

func (c *Model) IntegrityAtrib(ok bool) *Model

func (*Model) IntegrityReference

func (c *Model) IntegrityReference(ok bool) *Model

func (*Model) Low

func (c *Model) Low() string

func (*Model) Max added in v0.0.8

func (c *Model) Max(args ...any) *Column

func (*Model) Min added in v0.0.8

func (c *Model) Min(args ...any) *Column

func (*Model) Model

func (c *Model) Model() e.Json

func (*Model) Select

func (c *Model) Select(sel ...any) *Linq

func (*Model) SetUseSync added in v0.0.55

func (c *Model) SetUseSync(val bool) *Model

func (*Model) Sum added in v0.0.8

func (c *Model) Sum(args ...any) *Column

func (*Model) TitleIdx

func (c *Model) TitleIdx(name string) int

func (*Model) Trigger

func (c *Model) Trigger(event int, trigger Trigger)

* * *

func (*Model) Up

func (c *Model) Up() string

* * *

func (*Model) Update

func (c *Model) Update(data e.Json) *Linq

func (*Model) Upsert

func (c *Model) Upsert(data e.Json) *Linq

type OrderBy

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

* * *

type Reference

type Reference struct {
	Fkey      string
	Name      string
	Key       string
	Reference *Column
}

func NewForeignKey

func NewForeignKey(fKey string, reference *Column) *Reference

func (*Reference) DDL

func (c *Reference) DDL() string

func (*Reference) Describe

func (c *Reference) Describe() e.Json

type SQL

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

* * *

type Schema

type Schema struct {
	Db              int
	Database        *jdb.Db
	Name            string
	Description     string
	UseSync         bool
	SourceField     string
	DateMakeField   string
	DateUpdateField string
	IndexField      string
	CodeField       string
	ProjectField    string
	StateField      string
	Models          []*Model
}

func GetSchema

func GetSchema(name string) *Schema

func NewSchema

func NewSchema(db int, name string) *Schema

func (*Schema) Describe

func (c *Schema) Describe() e.Json

* * *

func (*Schema) Init

func (c *Schema) Init() error

func (*Schema) Model

func (c *Schema) Model(name string) *Model

* * *

func (*Schema) SetUseSync added in v0.0.55

func (c *Schema) SetUseSync(val bool) *Schema

type Trigger

type Trigger func(model *Model, old, new *e.Json, data e.Json) error

type Validate added in v0.0.69

type Validate struct {
	Col   *Column
	Value any
}

* * *

type Where

type Where struct {
	PrimaryKey *Validate
	// contains filtered or unexported fields
}

func NewWhere

func NewWhere(val1 any, operator string, val2 any) *Where

func (*Where) Def

func (c *Where) Def(val any) string

func (*Where) Define

func (c *Where) Define(linq *Linq) *Where

func (*Where) SetPrimaryKey added in v0.0.88

func (c *Where) SetPrimaryKey(col *Column, val any) *Where

func (*Where) Str1 added in v0.0.56

func (c *Where) Str1() string

func (*Where) Str2 added in v0.0.56

func (c *Where) Str2() string

Jump to

Keyboard shortcuts

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