ir

package
v1.0.0-...-1f0868f Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: Apache-2.0 Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Create

type Create struct {
	Suffix   []string
	Model    *Model
	Raw      bool
	NoReturn bool
}

func (*Create) AutoInsertableFields

func (cre *Create) AutoInsertableFields() (fields []*Field)

func (*Create) Fields

func (cre *Create) Fields() (fields []*Field)

func (*Create) InsertableFields

func (cre *Create) InsertableFields() (fields []*Field)

func (*Create) Signature

func (cre *Create) Signature() string

type Delete

type Delete struct {
	Suffix []string
	Model  *Model
	Joins  []*Join
	Where  []*Where
}

func (*Delete) Distinct

func (d *Delete) Distinct() bool

func (*Delete) Signature

func (r *Delete) Signature() string

type Expr

type Expr struct {
	Null        bool
	Placeholder bool
	StringLit   *string
	NumberLit   *string
	BoolLit     *bool
	Field       *Field
	FuncCall    *FuncCall
}

func (*Expr) HasPlaceholder

func (e *Expr) HasPlaceholder() bool

func (*Expr) Nullable

func (e *Expr) Nullable() bool

func (*Expr) Unique

func (e *Expr) Unique() bool

type Field

type Field struct {
	Name       string
	Column     string
	Model      *Model
	Type       consts.FieldType
	Relation   *Relation
	Nullable   bool
	AutoInsert bool
	AutoUpdate bool
	Updatable  bool
	Length     int // Text only
}

func (*Field) ColumnRef

func (f *Field) ColumnRef() string

func (*Field) Insertable

func (f *Field) Insertable() bool

func (*Field) IsInt

func (f *Field) IsInt() bool

func (*Field) IsTime

func (f *Field) IsTime() bool

func (*Field) ModelOf

func (f *Field) ModelOf() *Model

func (*Field) SelectRefs

func (f *Field) SelectRefs() (refs []string)

func (*Field) UnderRef

func (f *Field) UnderRef() string

func (*Field) Unique

func (f *Field) Unique() bool

type FuncCall

type FuncCall struct {
	Name string
	Args []*Expr
}

func (*FuncCall) HasPlaceholder

func (fc *FuncCall) HasPlaceholder() bool

func (*FuncCall) Nullable

func (fc *FuncCall) Nullable() bool

type GroupBy

type GroupBy struct {
	Fields []*Field
}

type Index

type Index struct {
	Name   string
	Model  *Model
	Fields []*Field
	Unique bool
}

type Join

type Join struct {
	Type  consts.JoinType
	Left  *Field
	Right *Field
}

type Model

type Model struct {
	Name       string
	Table      string
	Fields     []*Field
	PrimaryKey []*Field
	Unique     [][]*Field
	Indexes    []*Index
}

func SortModels

func SortModels(models []*Model) (sorted []*Model, err error)

func (*Model) AutoInsertableFields

func (m *Model) AutoInsertableFields() (fields []*Field)

func (*Model) AutoUpdatableFields

func (m *Model) AutoUpdatableFields() (fields []*Field)

func (*Model) BasicPrimaryKey

func (m *Model) BasicPrimaryKey() *Field

func (*Model) FieldSetUnique

func (m *Model) FieldSetUnique(fields []*Field) bool

func (*Model) FieldUnique

func (m *Model) FieldUnique(field *Field) bool

func (*Model) HasUpdatableFields

func (m *Model) HasUpdatableFields() bool

func (*Model) InsertableFields

func (m *Model) InsertableFields() (fields []*Field)

func (*Model) ModelOf

func (m *Model) ModelOf() *Model

func (*Model) SelectRefs

func (m *Model) SelectRefs() (refs []string)

func (*Model) UnderRef

func (m *Model) UnderRef() string

func (*Model) UpdatableFields

func (m *Model) UpdatableFields() (fields []*Field)

type OrderBy

type OrderBy struct {
	Fields     []*Field
	Descending bool
}

type Read

type Read struct {
	Suffix      []string
	Selectables []Selectable
	From        *Model
	Joins       []*Join
	Where       []*Where
	OrderBy     *OrderBy
	GroupBy     *GroupBy
	View        View
}

func (*Read) Distinct

func (r *Read) Distinct() bool

func (*Read) SelectedModel

func (r *Read) SelectedModel() *Model

SelectedModel returns the single model being selected or nil if there are more than one selectable or the selectable is a field.

func (*Read) Signature

func (r *Read) Signature() string

type Relation

type Relation struct {
	Field *Field
	Kind  consts.RelationKind
}

type Root

type Root struct {
	Models  []*Model
	Creates []*Create
	Reads   []*Read
	Updates []*Update
	Deletes []*Delete
}

type Selectable

type Selectable interface {
	SelectRefs() []string
	ModelOf() *Model
	// contains filtered or unexported methods
}

type Update

type Update struct {
	Suffix   []string
	Model    *Model
	Joins    []*Join
	Where    []*Where
	NoReturn bool
}

func (*Update) AutoUpdatableFields

func (upd *Update) AutoUpdatableFields() (fields []*Field)

func (*Update) One

func (upd *Update) One() bool

func (*Update) Signature

func (r *Update) Signature() string

type View

type View string
const (
	All         View = "all"
	LimitOffset View = "limitoffset"
	Paged       View = "paged"
	Count       View = "count"
	Has         View = "has"
	Scalar      View = "scalar"
	One         View = "one"
	First       View = "first"
)

type Where

type Where struct {
	Left  *Expr
	Op    consts.Operator
	Right *Expr
}

func (*Where) NeedsCondition

func (w *Where) NeedsCondition() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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