Documentation
¶
Index ¶
- type Access
- type Contract
- type ContractType
- type Entity
- func (e Entity) CanFieldRead(field Field) bool
- func (e Entity) CanFieldWrite(field Field) bool
- func (e Entity) GetContract(contractType ContractType) (Contract, bool)
- func (e Entity) GetFieldByName(name string) (Field, bool)
- func (e Entity) GetIdField() Field
- func (e Entity) HasPROTO() bool
- func (e Entity) HasSQLC() bool
- func (e Entity) IsFieldVirtual(field Field) bool
- func (e Entity) ProtoQueries() []Query
- func (e Entity) SQLCQueries() []Query
- type Field
- type FieldType
- type Index
- type IndexColumn
- type IndexType
- type Query
- type QueryFilter
- type QueryFilterType
- type QueryType
- type SQLDialect
- type Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶ added in v0.0.3
type Access string
Access narrows what a contract allows. Empty means both read and write.
type Contract ¶
type Contract struct {
Type ContractType
Access Access
}
type ContractType ¶
type ContractType string
const ( ContractSQLC ContractType = "sqlc" ContractPROTO ContractType = "proto" )
type Entity ¶
type Entity struct {
Name string
Comment string
Fields []Field
Contracts []Contract
Queries []Query
Indexes []Index
}
func FilterPROTO ¶
func FilterSQLC ¶
func (Entity) CanFieldRead ¶ added in v0.0.3
func (Entity) CanFieldWrite ¶ added in v0.0.3
func (Entity) GetContract ¶ added in v0.0.3
func (e Entity) GetContract(contractType ContractType) (Contract, bool)
func (Entity) GetIdField ¶
func (Entity) IsFieldVirtual ¶ added in v0.0.3
func (Entity) ProtoQueries ¶ added in v0.0.3
ProtoQueries returns the queries generated for the proto contract
func (Entity) SQLCQueries ¶ added in v0.0.3
SQLCQueries returns the queries generated for the sqlc contract
type Field ¶
type Field struct {
Name string
Type FieldType
Primary bool
Unique bool
DefaultValue any
DefaultFunc func() any
ProtoField int
Comment string
Contracts []Contract
Immutable bool
Optional bool
Validate func() any
}
func (Field) CanApiRead ¶ added in v0.0.3
func (Field) CanApiWrite ¶ added in v0.0.3
func (Field) CanDbWrite ¶ added in v0.0.3
func (Field) GetContract ¶ added in v0.0.3
func (f Field) GetContract(contractType ContractType) (Contract, bool)
GetContract returns the field contract of the given type
type Index ¶
type Index struct {
Type IndexType
Columns []IndexColumn
Unique bool
Name string
}
func (Index) FieldNames ¶
type IndexColumn ¶
type Query ¶
type Query struct {
Type QueryType
Fields []string
Filters []QueryFilter
Count bool
OrderBy string
Name string // custom query name; empty means auto-generated
Comment string
Contracts []Contract
}
func (Query) HasContract ¶ added in v0.0.3
func (q Query) HasContract(contractType ContractType) bool
type QueryFilter ¶
type QueryFilter struct {
Type QueryFilterType
Field string
Optional bool
}
type QueryFilterType ¶
type QueryFilterType string
const ( QueryFilterRange QueryFilterType = "range" QueryFilterSearch QueryFilterType = "search" QueryFilterEq QueryFilterType = "eq" )
type SQLDialect ¶
type SQLDialect string
const ( MySQL SQLDialect = "mysql" SQLite SQLDialect = "sqlite" PostgreSQL SQLDialect = "postgresql" )
Click to show internal directories.
Click to hide internal directories.