linq

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 9 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 TpCaption = 4
View Source
const TpClone = 6
View Source
const TpColumn = 0
View Source
const TpData = 2
View Source
const TpDetail = 2
View Source
const TpField = 7
View Source
const TpFunction = 5
View Source
const TpReference = 3
View Source
const TpRow = 1

Variables

View Source
var (
	SourceField     string = "_DATA"
	DateMakeField   string = "DATE_MAKE"
	DateUpdateField string = "DATE_UPDATE"
	SerieField      string = "INDEX"
	CodeField       string = "CODE"
	ProjectField    string = "PROJECT_ID"
	StateField      string = "_STATE"
	IdTFiled        string = "_IDT"
)

Functions

func Describe

func Describe(schema, model, filter string) et.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
	References  []*Column
	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() et.Json

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) ReferencesAdd added in v0.0.104

func (c *Column) ReferencesAdd(col *Column) int

func (*Column) ReferencesIdx added in v0.0.104

func (c *Column) ReferencesIdx(col *Column) int

* * References *

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 *et.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() (et.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() (et.Items, error)

* * Executors *

func (*Linq) CommandOne added in v0.0.88

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

func (*Linq) Count

func (s *Linq) Count() int

func (*Linq) Current

func (c *Linq) Current() (et.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 *et.Json) *et.Json

func (*Linq) Dev added in v0.0.103

func (c *Linq) Dev() *Linq

func (*Linq) Find

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

* * *

func (*Linq) First

func (s *Linq) First() (et.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) (et.Items, error)

func (*Linq) List

func (s *Linq) List(page, rows int) (et.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) (et.Items, error)

func (*Linq) PrepareDelete

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

func (*Linq) PrepareInsert

func (c *Linq) PrepareInsert() (et.Items, error)

* * Prepare command data *

func (*Linq) PrepareUpdate

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

func (*Linq) PrepareUpsert added in v0.0.86

func (c *Linq) PrepareUpsert() (et.Items, 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) 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 Listener added in v0.0.111

type Listener func(data et.Json)

type Model

type Model struct {
	Name            string
	Description     string
	Define          string
	Schema          *Schema
	Table           string
	Definition      []*Column
	PrimaryKeys     []string
	ForeignKey      []*Reference
	Index           []string
	SourceField     *Column
	DateMakeField   *Column
	DateUpdateField *Column
	SerieField      *Column
	CodeField       *Column
	ProjectField    *Column
	StateField      *Column
	IdTFiled        *Column
	Ddl             string

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

func NewModel

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

func Table added in v0.0.174

func Table(schema, name string) *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 et.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) Command added in v0.0.174

func (c *Model) Command(sql string, args ...any) (et.Item, error)

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) Db

func (c *Model) Db() *jdb.DB

* * Db * @return *jdb.DB *

func (*Model) DefineAtrib

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

func (*Model) DefineCaption added in v0.0.104

func (c *Model) DefineCaption(thisKey, name, otherKey string, column *Column, _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, showThisKey bool) *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) DeleteRow added in v0.0.104

func (c *Model) DeleteRow() *Linq

func (*Model) Describe

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

func (*Model) Details

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

func (*Model) DropDDL

func (c *Model) DropDDL() string

func (*Model) From

func (c *Model) From() *Linq

* * *

func (*Model) IndexAdd added in v0.0.104

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

func (*Model) IndexIdx added in v0.0.104

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

func (*Model) IndexSource added in v1.0.9

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

func (*Model) Init added in v0.0.29

func (c *Model) Init() error

* * DDL *

func (*Model) Insert

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

* * *

func (*Model) InsertRow added in v0.0.104

func (c *Model) InsertRow(data et.Json) *Linq

* * Row *

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() et.Json

func (*Model) Query added in v0.0.174

func (c *Model) Query(sql string, args ...any) (et.Items, error)

func (*Model) QueryOne added in v0.0.174

func (c *Model) QueryOne(sql string, args ...any) (et.Item, error)

func (*Model) Select

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

func (*Model) Source added in v0.0.174

func (c *Model) Source(sourceField, sql string, args ...any) (et.Items, error)

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 et.Json) *Linq

func (*Model) UpdateRow added in v0.0.104

func (c *Model) UpdateRow(data et.Json) *Linq

func (*Model) Upsert

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

func (*Model) UpsertRow added in v0.0.104

func (c *Model) UpsertRow(data et.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() et.Json

type SQL

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

* * *

type Schema

type Schema struct {
	Name        string
	Description string
	Define      string
	Models      []*Model
	// contains filtered or unexported fields
}

func GetSchema

func GetSchema(name string) *Schema

func NewSchema

func NewSchema(db *jdb.DB, name string) *Schema

func (*Schema) Describe

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

* * *

func (*Schema) Init

func (c *Schema) Init() error

func (*Schema) Model

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

* * *

type Trigger

type Trigger func(model *Model, old, new *et.Json, data et.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