Documentation
¶
Index ¶
- Constants
- Variables
- func AuthUserColumn(e *Entity) string
- func BuildDatabases(m *Model) map[string]*Database
- func ColumnSize(f *Field) int
- func ConstraintName(prefix string, parts ...string) string
- func JoinColumn(e *Entity) string
- func JoinPair(a, b *Entity) (*Entity, *Entity)
- func MigrationName(oldDB *Database, changes []Change) string
- func RelationPolicies(source, target *Entity) (list Policy, link Policy, ok bool)
- func SameDatabase(a, b *Entity) bool
- type Change
- type ChangeKind
- type Check
- type Column
- type ColumnKind
- type Database
- type DatabaseMode
- type Default
- type DefaultKind
- type Diagnostic
- type Diagnostics
- type DiffOptions
- type DiffResult
- type Entity
- func (e *Entity) AutoCreateField() *Field
- func (e *Entity) BelongsTo() []*Field
- func (e *Entity) CreateFields() []*Field
- func (e *Entity) DatabaseName() string
- func (e *Entity) Field(name string) *Field
- func (e *Entity) FieldNames() []string
- func (e *Entity) FilterFields() []*Field
- func (e *Entity) HasMethod(m Method) bool
- func (e *Entity) Identity() *Field
- func (e *Entity) IsAuth() bool
- func (e *Entity) LoginMethod() Method
- func (e *Entity) Owner() *Field
- func (e *Entity) PK() *Field
- func (e *Entity) Password() *Field
- func (e *Entity) Path() string
- func (e *Entity) PathParam() string
- func (e *Entity) Policy(op Operation) Policy
- func (e *Entity) Role() *Field
- func (e *Entity) UniqueFields() []*Field
- func (e *Entity) UpdateFields() []*Field
- func (e *Entity) Var() string
- type Field
- func (f *Field) Auto() bool
- func (f *Field) CrossService(owner *Entity) bool
- func (f *Field) External(owner *Entity) bool
- func (f *Field) Filterable() bool
- func (f *Field) GoType() string
- func (f *Field) InCreate() bool
- func (f *Field) InUpdate() bool
- func (f *Field) InputJSON() string
- func (f *Field) InputName() string
- type ForeignKey
- type Index
- type Kind
- type Method
- type Model
- type OnDelete
- type Operation
- type Operations
- type Policy
- type Pos
- type PrimaryKey
- type Reference
- type Relation
- type RelationKind
- type Service
- type Severity
- type Snapshot
- type Table
Constants ¶
View Source
const ( SessionsTable = "auth_sessions" RefreshTokensTable = "auth_refresh_tokens" APIKeysTable = "auth_api_keys" )
View Source
const ( TokenHashSize = 64 TokenIDSize = 32 KeyNameSize = 120 KeyPrefixSize = 16 PasswordSize = 255 )
View Source
const DeletedAtColumn = "deleted_at"
View Source
const MaxIdentifierLength = 63
View Source
const SnapshotVersion = 1
Variables ¶
View Source
var AuthTables = []string{APIKeysTable, RefreshTokensTable, SessionsTable}
View Source
var Methods = []Method{MethodSession, MethodJWT, MethodAPIKey}
Functions ¶
func AuthUserColumn ¶
func BuildDatabases ¶
func ColumnSize ¶
func ConstraintName ¶
func JoinColumn ¶
func MigrationName ¶
func RelationPolicies ¶
func SameDatabase ¶
Types ¶
type Change ¶
type Change struct {
Kind ChangeKind
TableName string
Table *Table
InlineFKs []*ForeignKey
Column *Column
OldColumn *Column
Index *Index
ForeignKey *ForeignKey
Check *Check
NewTable bool
}
type ChangeKind ¶
type ChangeKind string
const ( ChangeCreateTable ChangeKind = "create_table" ChangeDropTable ChangeKind = "drop_table" ChangeAddColumn ChangeKind = "add_column" ChangeDropColumn ChangeKind = "drop_column" ChangeAlterColumn ChangeKind = "alter_column" ChangeAddIndex ChangeKind = "add_index" ChangeDropIndex ChangeKind = "drop_index" ChangeAddForeignKey ChangeKind = "add_foreign_key" ChangeDropForeignKey ChangeKind = "drop_foreign_key" ChangeAddCheck ChangeKind = "add_check" ChangeDropCheck ChangeKind = "drop_check" )
type Column ¶
type Column struct {
Name string `json:"name"`
Kind ColumnKind `json:"kind"`
Size int `json:"size,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Identity bool `json:"identity,omitempty"`
Default *Default `json:"default,omitempty"`
}
func FieldColumn ¶
type ColumnKind ¶
type ColumnKind string
const ( ColumnString ColumnKind = "string" ColumnBool ColumnKind = "bool" ColumnInt16 ColumnKind = "int16" ColumnInt32 ColumnKind = "int32" ColumnInt64 ColumnKind = "int64" ColumnFloat32 ColumnKind = "float32" ColumnFloat64 ColumnKind = "float64" ColumnBytes ColumnKind = "bytes" ColumnTime ColumnKind = "time" ColumnUUID ColumnKind = "uuid" )
type Default ¶
type Default struct {
Kind DefaultKind `json:"kind"`
Value string `json:"value,omitempty"`
}
type DefaultKind ¶
type DefaultKind string
const ( DefaultLiteral DefaultKind = "literal" DefaultNow DefaultKind = "now" )
type Diagnostic ¶
type Diagnostic struct {
Pos
Severity Severity `json:"severity"`
Code string `json:"code"`
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
}
func (Diagnostic) String ¶
func (d Diagnostic) String() string
type Diagnostics ¶
type Diagnostics []Diagnostic
func (Diagnostics) Error ¶
func (ds Diagnostics) Error() string
func (Diagnostics) Errors ¶
func (ds Diagnostics) Errors() Diagnostics
func (Diagnostics) HasErrors ¶
func (ds Diagnostics) HasErrors() bool
func (Diagnostics) Sort ¶
func (ds Diagnostics) Sort()
func (Diagnostics) Warnings ¶
func (ds Diagnostics) Warnings() Diagnostics
type DiffOptions ¶
type DiffOptions struct {
RecreateDependents bool
}
type DiffResult ¶
func Diff ¶
func Diff(oldDB, newDB *Database, opts DiffOptions) DiffResult
func (DiffResult) Down ¶
func (r DiffResult) Down() []Change
func (DiffResult) Empty ¶
func (r DiffResult) Empty() bool
type Entity ¶
type Entity struct {
Name string
Domain string
File string
Pos Pos
Table string
SoftDelete bool
NoRoutes bool
ReadOnly bool
UUIDImport string
Service *Service
Auth []Method
Register bool
Public Operations
Roles []string
WriteRoles []string
Fields []*Field
Relations []*Relation
}
func (*Entity) AutoCreateField ¶
func (*Entity) CreateFields ¶
func (*Entity) DatabaseName ¶
func (*Entity) FieldNames ¶
func (*Entity) FilterFields ¶
func (*Entity) LoginMethod ¶
func (*Entity) UniqueFields ¶
func (*Entity) UpdateFields ¶
type Field ¶
type Field struct {
Name string
Kind Kind
Nullable bool
Column string
JSON string
Pos Pos
PK bool
AutoPK bool
AutoCreate bool
AutoUpdate bool
Required bool
NotEmpty bool
Unique bool
Index bool
Email bool
Min string
Max string
Enum []string
Default string
HasDefault bool
OmitCreate bool
OmitUpdate bool
OmitResponse bool
Ref *Reference
Identity bool
Password bool
Role bool
Owner bool
}
func (*Field) CrossService ¶
func (*Field) Filterable ¶
type ForeignKey ¶
type Operations ¶
func (Operations) Any ¶
func (o Operations) Any() bool
func (Operations) Has ¶
func (o Operations) Has(op Operation) bool
func (*Operations) Set ¶
func (o *Operations) Set(op Operation)
type Pos ¶
type PrimaryKey ¶
type Relation ¶
func (*Relation) PathSegment ¶
type RelationKind ¶
type RelationKind string
const ( RelationHasMany RelationKind = "has_many" RelationManyToMany RelationKind = "many_to_many" )
type Service ¶
type Service struct {
Name string
TypeName string
File string
Pos Pos
Database DatabaseMode
Entities []*Entity
}
func (*Service) DatabaseName ¶
type Snapshot ¶
type Snapshot struct {
Version int `json:"version"`
Dialect string `json:"dialect"`
Migrations []string `json:"migrations"`
Tables []*Table `json:"tables"`
}
func UnmarshalSnapshot ¶
type Table ¶
type Table struct {
Name string `json:"name"`
Columns []*Column `json:"columns"`
PrimaryKey *PrimaryKey `json:"primaryKey"`
Indexes []*Index `json:"indexes,omitempty"`
ForeignKeys []*ForeignKey `json:"foreignKeys,omitempty"`
Checks []*Check `json:"checks,omitempty"`
}
func (*Table) ForeignKey ¶
func (t *Table) ForeignKey(name string) *ForeignKey
Click to show internal directories.
Click to hide internal directories.