schema

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contract

type Contract struct {
	Type ContractType
}

type ContractType

type ContractType string
const (
	ContractSQLC  ContractType = "sqlc"
	ContractPROTO ContractType = "proto"
)

type Entity

type Entity struct {
	Name      string
	Fields    []Field
	Contracts []Contract
	Queries   []Query
	Indexes   []Index
}

func FilterPROTO

func FilterPROTO(entities []Entity) []Entity

func FilterSQLC

func FilterSQLC(entities []Entity) []Entity

func (Entity) GetFieldByName

func (e Entity) GetFieldByName(name string) (Field, bool)

func (Entity) GetIdField

func (e Entity) GetIdField() Field

func (Entity) HasPROTO

func (e Entity) HasPROTO() bool

func (Entity) HasSQLC

func (e Entity) HasSQLC() bool

type Field

type Field struct {
	Name         string
	Type         FieldType
	Primary      bool
	Unique       bool
	DefaultValue any
	DefaultFunc  func() any
	ProtoField   int
	Comment      string
	Permissions  permissions.Permission
	Immutable    bool
	Optional     bool
	Validate     func() any
}

func (Field) IsID

func (f Field) IsID() bool

func (Field) IsVirtual

func (f Field) IsVirtual() bool

IsVirtual reports a field that live only in proto and not in sqlc

type FieldType

type FieldType string
const (
	FieldTypeString FieldType = "string"
	FieldTypeInt    FieldType = "int32"
	FieldTypeInt64  FieldType = "int64"
	FieldTypeFloat  FieldType = "float64"
	FieldTypeBool   FieldType = "bool"
	FieldTypeTime   FieldType = "time"
	FieldTypeByte   FieldType = "[]byte"
	FieldTypeJSON   FieldType = "json"
)

type Index

type Index struct {
	Type    IndexType
	Columns []IndexColumn
	Unique  bool
	Name    string
}

func (Index) FieldNames

func (i Index) FieldNames() []string

type IndexColumn

type IndexColumn struct {
	Name string
	Desc bool // false = ASC (default), true = DESC
}

type IndexType

type IndexType string
const (
	IndexPrimary IndexType = "primary"
	IndexRegular IndexType = "index"
)

type Query

type Query struct {
	Type    QueryType
	Fields  []string
	Filters []QueryFilter
	Count   bool
	OrderBy string
	Name    string // custom query name; empty means auto-generated
}

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 QueryType

type QueryType string
const (
	QueryCreate     QueryType = "create"
	QueryCreateBulk QueryType = "create_bulk"
	QueryUpdate     QueryType = "update"
	QueryDelete     QueryType = "delete"
	QueryDeleteAll  QueryType = "delete_all"
	QueryGetBy      QueryType = "get_by"
	QueryListBy     QueryType = "list_by"
	QueryListAll    QueryType = "list_all"
)

type SQLDialect

type SQLDialect string
const (
	MySQL      SQLDialect = "mysql"
	SQLite     SQLDialect = "sqlite"
	PostgreSQL SQLDialect = "postgresql"
)

type Schema

type Schema struct {
	Entities []Entity
}

Jump to

Keyboard shortcuts

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