Documentation
¶
Index ¶
- type Column
- func (c *Column) Default(value any) *Column
- func (c *Column) Encrypted() *Column
- func (c *Column) ForeignKey(table, column string) *Column
- func (c *Column) IsOwner() *Column
- func (c *Column) NotNull() *Column
- func (c *Column) Nullable() *Column
- func (c *Column) OwnerSees() *Column
- func (c *Column) PrimaryKey() *Column
- func (c *Column) Public() *Column
- func (c *Column) RoleSees(slug string) *Column
- func (c *Column) Sealed() *Column
- func (c *Column) Unique() *Column
- func (c *Column) UnsafePublic() *Column
- type ColumnType
- type ControllerActionDef
- type DriverCapabilities
- type ExposeBuilder
- func (e *ExposeBuilder) All()
- func (e *ExposeBuilder) Create()
- func (e *ExposeBuilder) Delete()
- func (e *ExposeBuilder) List()
- func (e *ExposeBuilder) RemoveCreate()
- func (e *ExposeBuilder) RemoveDelete()
- func (e *ExposeBuilder) RemoveList()
- func (e *ExposeBuilder) RemoveShow()
- func (e *ExposeBuilder) RemoveUpdate()
- func (e *ExposeBuilder) Show()
- func (e *ExposeBuilder) Update()
- type ExposedOperation
- type GraphQLOperation
- type GraphQLPolicy
- func (p *GraphQLPolicy) AlterExpose(model string, fn func(*ExposeBuilder))
- func (p *GraphQLPolicy) ControllerAction(name string, handler interface{})
- func (p *GraphQLPolicy) Expose(model string, fn func(*ExposeBuilder))
- func (p *GraphQLPolicy) GetOperations() []GraphQLOperation
- func (p *GraphQLPolicy) RemoveAction(name string)
- func (p *GraphQLPolicy) Reset()
- func (p *GraphQLPolicy) Transactional() bool
- func (p *GraphQLPolicy) Unexpose(model string)
- type Index
- type Migration
- func (m *Migration) AddColumn(table string, fn func(*Table))
- func (m *Migration) AddIndex(table string, columns ...string)
- func (m *Migration) AddUniqueIndex(table string, columns ...string)
- func (m *Migration) AlterTable(name string, fn func(*Table))
- func (m *Migration) Connection() string
- func (m *Migration) CreateTable(name string, fn func(*Table))
- func (m *Migration) CreateView(name string, fn func(*View))
- func (m *Migration) DropColumn(table, column string)
- func (m *Migration) DropTableIfExists(name string)
- func (m *Migration) DropView(name string)
- func (m *Migration) GetOperations() []Operation
- func (m *Migration) RenameColumn(table, oldName, newName string)
- func (m *Migration) RenameTable(oldName, newName string)
- func (m *Migration) Reset()
- func (m *Migration) Transactional() bool
- type Operation
- type Policy
- type Relationship
- type RelationshipType
- type RoleBuilder
- func (b *RoleBuilder) Can(actions ...string) *RoleBuilder
- func (b *RoleBuilder) Default() *RoleBuilder
- func (b *RoleBuilder) Manages() *RoleBuilder
- func (b *RoleBuilder) Name(name string) *RoleBuilder
- func (b *RoleBuilder) RemoveDefault() *RoleBuilder
- func (b *RoleBuilder) RemoveManages() *RoleBuilder
- func (b *RoleBuilder) RevokeCan(actions ...string) *RoleBuilder
- type RoleDefinition
- type RoleOperation
- type Table
- func (t *Table) AppendOnly()
- func (t *Table) BigInteger(name string) *Column
- func (t *Table) Binary(name string) *Column
- func (t *Table) Boolean(name string) *Column
- func (t *Table) Date(name string) *Column
- func (t *Table) Decimal(name string, precision, scale int) *Column
- func (t *Table) Double(name string) *Column
- func (t *Table) Float(name string) *Column
- func (t *Table) HasMany(name string, fn func(*Table)) *Relationship
- func (t *Table) HasOne(name string, fn func(*Table)) *Relationship
- func (t *Table) Immutable()
- func (t *Table) Integer(name string) *Column
- func (t *Table) JSONB(name string) *Column
- func (t *Table) SoftDeletes()
- func (t *Table) String(name string, length ...int) *Column
- func (t *Table) Text(name string) *Column
- func (t *Table) Time(name string) *Column
- func (t *Table) Timestamp(name string) *Column
- func (t *Table) Timestamps()
- func (t *Table) UUID(name string) *Column
- type TableOperation
- type View
- type ViewColumn
- func (vc *ViewColumn) BigInteger() *ViewColumn
- func (vc *ViewColumn) BooleanType() *ViewColumn
- func (vc *ViewColumn) Decimal(precision, scale int) *ViewColumn
- func (vc *ViewColumn) IntegerType() *ViewColumn
- func (vc *ViewColumn) JSONBType() *ViewColumn
- func (vc *ViewColumn) OutputName() string
- func (vc *ViewColumn) StringType(length ...int) *ViewColumn
- func (vc *ViewColumn) TextType() *ViewColumn
- func (vc *ViewColumn) TimestampType() *ViewColumn
- func (vc *ViewColumn) UUIDType() *ViewColumn
- type ViewSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct {
Name string
Type ColumnType
Length int
Precision int
Scale int
IsPrimaryKey bool
IsNullable bool
IsUnique bool
DefaultValue any
HasDefault bool
ForeignKeyTable string
ForeignKeyColumn string
IsPublic bool
IsOwnerSees bool
IsOwnerColumn bool
IsEncrypted bool
IsSealed bool
IsUnsafePublic bool
FKMetadataOnly bool // FK is for ORM relationship metadata only; no SQL REFERENCES constraint
VisibleTo map[string]bool // role slugs that can see this column
}
Column represents a database column definition.
func (*Column) ForeignKey ¶
func (*Column) IsOwner ¶
IsOwner marks this column as the ownership column for the table. The value of this column is compared against the authenticated user's ID to determine ownership. Only one column per table may be marked as owner.
func (*Column) PrimaryKey ¶
func (*Column) Sealed ¶
Sealed marks this column as requiring non-deterministic encryption at rest (AES-256-GCM). Sealed columns cannot be searched — no WHERE scopes are generated.
func (*Column) UnsafePublic ¶
UnsafePublic explicitly acknowledges that a sensitive-named column is intentionally marked Public. Without this, Squeeze flags the Public/sensitive combination as an error.
type ColumnType ¶
type ColumnType int
ColumnType represents the data type of a database column.
const ( UUID ColumnType = iota String Text Integer BigInteger Decimal Boolean Timestamp JSONB Date Time Binary Float Double )
func (ColumnType) String ¶
func (t ColumnType) String() string
type ControllerActionDef ¶
type ControllerActionDef struct {
Name string
Handler interface{}
}
ControllerActionDef describes a custom controller action exposed as a GraphQL mutation.
type DriverCapabilities ¶
type DriverCapabilities struct {
TransactionalDDL bool // Can run DDL inside a transaction (Postgres: yes, MySQL: no)
ConcurrentIndexing bool // Supports CREATE INDEX CONCURRENTLY (Postgres)
JSONBSupport bool // Native JSONB type (Postgres)
UUIDNativeType bool // Native UUID type (Postgres)
AdvisoryLocks bool // Advisory lock support (Postgres)
ForeignKeys bool // Foreign key constraints (SQL: yes, doc stores: no)
EmbeddedDocs bool // Embedded subdocuments (MongoDB, DynamoDB: yes)
SecondaryIndex bool // Secondary indexes
UniqueIndex bool // Unique index constraints
}
DriverCapabilities describes what a database driver supports. Used by the generator to make storage strategy decisions for nested schemas and query layer generation.
func DriverCaps ¶
func DriverCaps(driver string) DriverCapabilities
DriverCaps returns capabilities for a given driver name.
type ExposeBuilder ¶
type ExposeBuilder struct {
// contains filtered or unexported fields
}
ExposeBuilder provides a fluent API for defining which operations to expose.
func (*ExposeBuilder) All ¶
func (e *ExposeBuilder) All()
All adds all five CRUD operations (list, show, create, update, delete).
func (*ExposeBuilder) RemoveCreate ¶
func (e *ExposeBuilder) RemoveCreate()
RemoveCreate marks the create operation for removal (alter only).
func (*ExposeBuilder) RemoveDelete ¶
func (e *ExposeBuilder) RemoveDelete()
RemoveDelete marks the delete operation for removal (alter only).
func (*ExposeBuilder) RemoveList ¶
func (e *ExposeBuilder) RemoveList()
RemoveList marks the list operation for removal (alter only).
func (*ExposeBuilder) RemoveShow ¶
func (e *ExposeBuilder) RemoveShow()
RemoveShow marks the show operation for removal (alter only).
func (*ExposeBuilder) RemoveUpdate ¶
func (e *ExposeBuilder) RemoveUpdate()
RemoveUpdate marks the update operation for removal (alter only).
type ExposedOperation ¶
type ExposedOperation struct {
Type string // "list", "show", "create", "update", "delete"
}
ExposedOperation describes a single CRUD operation exposed over GraphQL.
type GraphQLOperation ¶
type GraphQLOperation struct {
Type string // "expose", "alter_expose", "unexpose", "controller_action", "remove_action"
Model string
Ops []ExposedOperation
Action *ControllerActionDef
}
GraphQLOperation records a single GraphQL exposure change.
type GraphQLPolicy ¶
type GraphQLPolicy struct {
Operations []GraphQLOperation
}
GraphQLPolicy is the base type embedded by all GraphQL exposure policy structs. It records GraphQL exposure operations for later execution or inspection.
func (*GraphQLPolicy) AlterExpose ¶
func (p *GraphQLPolicy) AlterExpose(model string, fn func(*ExposeBuilder))
AlterExpose modifies the exposed operations for an already-exposed model.
func (*GraphQLPolicy) ControllerAction ¶
func (p *GraphQLPolicy) ControllerAction(name string, handler interface{})
ControllerAction registers a custom controller action as a GraphQL mutation.
func (*GraphQLPolicy) Expose ¶
func (p *GraphQLPolicy) Expose(model string, fn func(*ExposeBuilder))
Expose registers a model with the specified operations for GraphQL exposure.
func (*GraphQLPolicy) GetOperations ¶
func (p *GraphQLPolicy) GetOperations() []GraphQLOperation
GetOperations returns the operations recorded by Up() or Down().
func (*GraphQLPolicy) RemoveAction ¶
func (p *GraphQLPolicy) RemoveAction(name string)
RemoveAction removes a previously registered controller action.
func (*GraphQLPolicy) Reset ¶
func (p *GraphQLPolicy) Reset()
Reset clears recorded operations so the policy struct can be reused.
func (*GraphQLPolicy) Transactional ¶
func (p *GraphQLPolicy) Transactional() bool
Transactional returns true — policies run in a transaction by default.
func (*GraphQLPolicy) Unexpose ¶
func (p *GraphQLPolicy) Unexpose(model string)
Unexpose removes a model entirely from the GraphQL schema.
type Migration ¶
type Migration struct {
Operations []Operation
}
Migration is the base type embedded by all migration structs. It records schema operations for later execution or inspection.
func (*Migration) AddUniqueIndex ¶
func (*Migration) AlterTable ¶
AlterTable allows adding columns and nested relationships to an existing table.
func (*Migration) Connection ¶
Connection returns the database connection name this migration targets. Returns "" to use the default connection. Override in concrete migration structs to target a specific named connection from config/database.go.
func (*Migration) CreateTable ¶
func (*Migration) CreateView ¶
func (*Migration) DropColumn ¶
func (*Migration) DropTableIfExists ¶
func (*Migration) GetOperations ¶
GetOperations returns the operations recorded by Up() or Down().
func (*Migration) RenameColumn ¶
func (*Migration) RenameTable ¶
func (*Migration) Reset ¶
func (m *Migration) Reset()
Reset clears recorded operations so the migration struct can be reused.
func (*Migration) Transactional ¶
Transactional returns true — migrations run in a transaction by default. Override in concrete migration structs to opt out.
type Operation ¶
type Operation struct {
Type TableOperation
Table string
TableDef *Table
ViewDef *View
Index *Index
NewName string // for rename operations
OldName string // for rename operations
ColumnName string // for drop/rename column
ColumnDef func(*Table)
}
Operation records a single schema change.
type Policy ¶
type Policy struct {
Operations []RoleOperation
}
Policy is the base type embedded by all role policy structs. It records role operations for later execution or inspection.
func (*Policy) AlterRole ¶
func (p *Policy) AlterRole(slug string) *RoleBuilder
AlterRole begins a role alteration operation.
func (*Policy) CreateRole ¶
func (p *Policy) CreateRole(slug string) *RoleBuilder
CreateRole begins a role creation operation.
func (*Policy) GetOperations ¶
func (p *Policy) GetOperations() []RoleOperation
GetOperations returns the operations recorded by Up() or Down().
func (*Policy) Reset ¶
func (p *Policy) Reset()
Reset clears recorded operations so the policy struct can be reused.
func (*Policy) Transactional ¶
Transactional returns true — policies run in a transaction by default.
type Relationship ¶
type Relationship struct {
Type RelationshipType
Name string // child table name (e.g., "posts")
ChildTable *Table // child schema definition
ParentTable string // parent table name (set during CreateTable)
IsCollection bool // .Collection() — separate collection for doc stores
IsTopLevel bool // .TopLevelModel() — generate at models/ not models/parent/
}
Relationship records a nested child table declared via HasMany/HasOne.
func (*Relationship) Collection ¶
func (r *Relationship) Collection() *Relationship
func (*Relationship) TopLevelModel ¶
func (r *Relationship) TopLevelModel() *Relationship
type RelationshipType ¶
type RelationshipType int
RelationshipType distinguishes HasMany from HasOne.
const ( RelHasMany RelationshipType = iota RelHasOne )
type RoleBuilder ¶
type RoleBuilder struct {
// contains filtered or unexported fields
}
RoleBuilder provides a fluent API for defining role operations.
func (*RoleBuilder) Can ¶
func (b *RoleBuilder) Can(actions ...string) *RoleBuilder
Can grants the specified actions to this role.
func (*RoleBuilder) Default ¶
func (b *RoleBuilder) Default() *RoleBuilder
Default marks this role as the default role for new users.
func (*RoleBuilder) Manages ¶
func (b *RoleBuilder) Manages() *RoleBuilder
Manages marks this role as a managing role.
func (*RoleBuilder) Name ¶
func (b *RoleBuilder) Name(name string) *RoleBuilder
Name sets the display name for the role.
func (*RoleBuilder) RemoveDefault ¶
func (b *RoleBuilder) RemoveDefault() *RoleBuilder
RemoveDefault removes the default flag from this role.
func (*RoleBuilder) RemoveManages ¶
func (b *RoleBuilder) RemoveManages() *RoleBuilder
RemoveManages removes the manages flag from this role.
func (*RoleBuilder) RevokeCan ¶
func (b *RoleBuilder) RevokeCan(actions ...string) *RoleBuilder
RevokeCan removes the specified actions from this role (alter only).
type RoleDefinition ¶
type RoleDefinition struct {
Slug string
DisplayName string
IsManages bool
IsDefault bool
Actions []string
// Used by alter operations to track removals.
RemoveManages bool
RemoveDefault bool
RevokeActions []string
}
RoleDefinition describes a role and its permissions.
type RoleOperation ¶
type RoleOperation struct {
Type string // "create", "alter", "drop"
Role RoleDefinition
}
RoleOperation records a single role lifecycle change.
type Table ¶
type Table struct {
Name string
Connection string // database connection name ("" = default)
Columns []*Column
Relationships []*Relationship
IsImmutable bool // set by Immutable() — versioned, (id, version_id) composite PK
IsAppendOnly bool // set by AppendOnly() — insert-only, single id PK, no updates/deletes
HasSoftDelete bool // set by SoftDeletes() — adds deleted_at nullable column
}
Table collects column definitions for a database table.
func (*Table) AppendOnly ¶
func (t *Table) AppendOnly()
AppendOnly marks this table as insert-only. Pickle injects a single id primary key. The generated query type has no Update or Delete methods. CreatedAt is derived from the UUID v7 timestamp in id. Use this for financial ledgers, event logs, and audit journals where records must never be modified after creation.
func (*Table) BigInteger ¶
func (*Table) Double ¶
Double adds a double-precision floating-point column (SQL DOUBLE PRECISION). In almost all cases you should use Decimal(name, precision, scale) instead.
func (*Table) Float ¶
Float adds a single-precision floating-point column (SQL REAL / FLOAT). In almost all cases you should use Decimal(name, precision, scale) instead.
func (*Table) HasMany ¶
func (t *Table) HasMany(name string, fn func(*Table)) *Relationship
HasMany declares a one-to-many relationship. The child table gets an auto-injected FK column pointing back to this table's primary key.
func (*Table) HasOne ¶
func (t *Table) HasOne(name string, fn func(*Table)) *Relationship
HasOne declares a one-to-one relationship. The child table gets an auto-injected unique FK column pointing back to this table's primary key.
func (*Table) Immutable ¶
func (t *Table) Immutable()
Immutable marks this table as append-only. Pickle injects id and version_id as a composite primary key and generates insert-on-update query behaviour. Do not call Timestamps() on an immutable table — created_at and updated_at are derived from the UUID v7 timestamps embedded in id and version_id.
func (*Table) SoftDeletes ¶
func (t *Table) SoftDeletes()
SoftDeletes adds a nullable deleted_at timestamp column. On an immutable table, Delete() inserts a new version with deleted_at set. On a mutable table, Delete() issues a standard soft-delete UPDATE. Panics on append-only tables — append-only records cannot be deleted.
func (*Table) Timestamps ¶
func (t *Table) Timestamps()
Timestamps adds created_at and updated_at columns with NOW() defaults. Panics if called on an immutable or append-only table — those derive timestamps from UUID v7.
type TableOperation ¶
type TableOperation int
TableOperation represents a schema change recorded by a migration.
const ( OpCreateTable TableOperation = iota OpDropTableIfExists OpRenameTable OpAddColumn OpDropColumn OpRenameColumn OpAddIndex OpAddUniqueIndex OpCreateView OpDropView )
type View ¶
type View struct {
Name string
Sources []ViewSource
Columns []*ViewColumn
GroupByCols []string
}
View represents a database view definition.
func (*View) Column ¶
Column adds a column reference from a source table. ref is "alias.column" (e.g. "t.id"). An optional second argument aliases the output.
func (*View) SelectRaw ¶
func (v *View) SelectRaw(name, expr string) *ViewColumn
SelectRaw adds a computed column with a raw SQL expression. Returns the ViewColumn so the caller can chain type builder methods.
type ViewColumn ¶
type ViewColumn struct {
Column // embedded — carries Name, Type, Precision, Scale, IsNullable
SourceAlias string // e.g. "t" from "t.id"
SourceColumn string // e.g. "id" from "t.id"
OutputAlias string // optional alias for the output column name
RawExpr string // raw SQL expression (for SelectRaw)
}
ViewColumn represents a column in a view's SELECT list.
func (*ViewColumn) BigInteger ¶
func (vc *ViewColumn) BigInteger() *ViewColumn
func (*ViewColumn) BooleanType ¶
func (vc *ViewColumn) BooleanType() *ViewColumn
func (*ViewColumn) Decimal ¶
func (vc *ViewColumn) Decimal(precision, scale int) *ViewColumn
func (*ViewColumn) IntegerType ¶
func (vc *ViewColumn) IntegerType() *ViewColumn
func (*ViewColumn) JSONBType ¶
func (vc *ViewColumn) JSONBType() *ViewColumn
func (*ViewColumn) OutputName ¶
func (vc *ViewColumn) OutputName() string
OutputName returns the column name as it appears in the view's output.
func (*ViewColumn) StringType ¶
func (vc *ViewColumn) StringType(length ...int) *ViewColumn
func (*ViewColumn) TextType ¶
func (vc *ViewColumn) TextType() *ViewColumn
func (*ViewColumn) TimestampType ¶
func (vc *ViewColumn) TimestampType() *ViewColumn
func (*ViewColumn) UUIDType ¶
func (vc *ViewColumn) UUIDType() *ViewColumn