linq

package
v1.1.65 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 10 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

This section is empty.

Functions

func Describe

func Describe(schema, model, filter string) et.Json

func FunctionDef

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

func GetAs

func GetAs(n int) string

* * *

func SetListener added in v1.1.48

func SetListener(db *jdb.DB)

* * SetListener * @param db *jdb.DB *

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

func (c *Column) ColName() string

func (*Column) DDL

func (c *Column) DDL() string

* * DDL *

func (*Column) DDLIndex

func (c *Column) DDLIndex() string

func (*Column) DDLUniqueIndex

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

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

func (*Column) ReferencesIdx

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

* * References *

func (*Column) Search added in v1.1.1

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

func (*Column) Up

func (c *Column) Up() string

* * *

func (*Column) Valid

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

type DefaultField added in v1.1.42

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

func (DefaultField) Low added in v1.1.42

func (s DefaultField) Low() string

func (DefaultField) Origin added in v1.1.42

func (s DefaultField) Origin() string

func (DefaultField) Upp added in v1.1.42

func (s DefaultField) Upp() string

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

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

func (*Linq) AddValidate

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

func (*Linq) All

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)

* * Command * @return et.Items * @return error *

func (*Linq) CommandOne

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

* * CommandOne * @return et.Item * @return error *

func (*Linq) Count

func (s *Linq) Count() int

func (*Linq) Current

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

* * *

func (*Linq) Data

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

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

* * Go * @return et.Item * @return error *

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

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

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

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

type Listener func(data et.Json)

type Model

type Model struct {
	Name            string
	Description     string
	Define          string
	Functions       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
	DdlIndex        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 Mutation added in v1.1.1

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

func NewModel

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

func Table

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

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

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

* * *

func (*Model) Consolidate

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

* * *

func (*Model) Count

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

func (*Model) DDL

func (c *Model) DDL() string

func (*Model) DDLFunction added in v1.0.60

func (c *Model) DDLFunction() string

func (*Model) DDLMigration

func (c *Model) DDLMigration() string

func (*Model) Data

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

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

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

func (*Model) DefineUniqueIndex

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

func (*Model) Delete

func (c *Model) Delete() *Linq

func (*Model) DeleteRow

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) Exec added in v1.1.0

func (c *Model) Exec(id, sql string, args ...any) error

func (*Model) From

func (c *Model) From() *Linq

* * *

func (*Model) IndexAdd

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

func (*Model) IndexIdx

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

func (*Model) IndexSource

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

func (*Model) Init

func (c *Model) Init() error

* * DDL *

func (*Model) Insert

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

* * *

func (*Model) InsertRow

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

* * Low * @return string *

func (*Model) Max

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

func (*Model) Min

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

func (*Model) Model

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

func (*Model) NexCode

func (c *Model) NexCode(tag, prefix string) string

* * NextCode * @param tag string * @param prefix string * @return string *

func (*Model) NextSerie

func (c *Model) NextSerie(tag string) int64

* * NextSerie * @param tag string * @return int64 *

func (*Model) Query

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

func (*Model) QueryOne

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

func (*Model) Select

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

func (*Model) Source

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

func (*Model) Sum

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

* * Up * @return string *

func (*Model) Update

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

func (*Model) UpdateRow

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

func (*Model) Upsert

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

func (*Model) UpsertRow

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

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

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

func (*Where) Str1

func (c *Where) Str1() string

func (*Where) Str2

func (c *Where) Str2() string

Jump to

Keyboard shortcuts

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