functional

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package database provides PostgreSQL database-level object builders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckOption

type CheckOption string

CheckOption controls view CHECK OPTION behavior.

const (
	LocalCheckOption    CheckOption = "LOCAL"
	CascadedCheckOption CheckOption = "CASCADED"
)

type Function

type Function struct {
	// contains filtered or unexported fields
}

Function builds CREATE FUNCTION statements.

func NewFunction

func NewFunction(name string) *Function

NewFunction creates a function builder.

func (*Function) Apply

func (f *Function) Apply(ctx context.Context, ds *pgxext.DataSource) error

Apply creates or replaces the function.

func (*Function) Body

func (f *Function) Body(body string) *Function

Body sets the function body.

func (*Function) BuildSQL

func (f *Function) BuildSQL() (string, error)

BuildSQL builds CREATE FUNCTION SQL.

func (*Function) Drop

func (f *Function) Drop(ctx context.Context, ds *pgxext.DataSource, ifExists bool) error

Drop drops the function.

func (*Function) DropSQL

func (f *Function) DropSQL(ifExists bool) (string, error)

DropSQL builds DROP FUNCTION SQL.

func (*Function) Language

func (f *Function) Language(language string) *Function

Language sets the function language.

func (*Function) OrReplace

func (f *Function) OrReplace() *Function

OrReplace emits CREATE OR REPLACE FUNCTION.

func (*Function) Returns

func (f *Function) Returns(returnType string) *Function

Returns sets the function return type.

func (*Function) SecurityDefiner

func (f *Function) SecurityDefiner() *Function

SecurityDefiner emits SECURITY DEFINER.

func (*Function) Strict

func (f *Function) Strict() *Function

Strict emits STRICT.

func (*Function) WithArguments

func (f *Function) WithArguments(args ...string) *Function

WithArguments sets the function arguments.

func (*Function) WithVolatility

func (f *Function) WithVolatility(volatility Volatility) *Function

WithVolatility sets VOLATILE, STABLE, or IMMUTABLE.

type MaterializedView

type MaterializedView struct {
	// contains filtered or unexported fields
}

MaterializedView builds CREATE MATERIALIZED VIEW statements.

func NewMaterializedView

func NewMaterializedView(name string) *MaterializedView

NewMaterializedView creates a materialized view builder.

func (*MaterializedView) Apply

Apply creates the materialized view.

func (*MaterializedView) As

As sets the SELECT query backing the materialized view.

func (*MaterializedView) BuildSQL

func (v *MaterializedView) BuildSQL() (string, error)

BuildSQL builds CREATE MATERIALIZED VIEW SQL.

func (*MaterializedView) Drop

func (v *MaterializedView) Drop(ctx context.Context, ds *pgxext.DataSource, ifExists bool) error

Drop drops the materialized view.

func (*MaterializedView) DropSQL

func (v *MaterializedView) DropSQL(ifExists bool) (string, error)

DropSQL builds DROP MATERIALIZED VIEW SQL.

func (*MaterializedView) IfNotExists

func (v *MaterializedView) IfNotExists() *MaterializedView

IfNotExists emits CREATE MATERIALIZED VIEW IF NOT EXISTS.

func (*MaterializedView) InTablespace

func (v *MaterializedView) InTablespace(name string) *MaterializedView

InTablespace adds TABLESPACE.

func (*MaterializedView) Refresh

func (v *MaterializedView) Refresh(ctx context.Context, ds *pgxext.DataSource, concurrently bool, withData bool) error

Refresh refreshes the materialized view.

func (*MaterializedView) RefreshSQL

func (v *MaterializedView) RefreshSQL(concurrently bool, withData bool) (string, error)

RefreshSQL builds REFRESH MATERIALIZED VIEW SQL.

func (*MaterializedView) WithData

func (v *MaterializedView) WithData() *MaterializedView

WithData creates the materialized view and populates it.

func (*MaterializedView) WithNoData

func (v *MaterializedView) WithNoData() *MaterializedView

WithNoData creates the materialized view without populating it.

func (*MaterializedView) WithStorageParameter

func (v *MaterializedView) WithStorageParameter(name, value string) *MaterializedView

WithStorageParameter adds a WITH storage parameter.

type View

type View struct {
	// contains filtered or unexported fields
}

View builds CREATE VIEW statements.

func NewView

func NewView(name string) *View

NewView creates a view builder.

func (*View) Apply

func (v *View) Apply(ctx context.Context, ds *pgxext.DataSource) error

Apply creates or replaces the view.

func (*View) As

func (v *View) As(query string) *View

As sets the SELECT query backing the view.

func (*View) BuildSQL

func (v *View) BuildSQL() (string, error)

BuildSQL builds CREATE VIEW SQL.

func (*View) Drop

func (v *View) Drop(ctx context.Context, ds *pgxext.DataSource, ifExists bool) error

Drop drops the view.

func (*View) DropSQL

func (v *View) DropSQL(ifExists bool) (string, error)

DropSQL builds DROP VIEW SQL.

func (*View) OrReplace

func (v *View) OrReplace() *View

OrReplace emits CREATE OR REPLACE VIEW.

func (*View) WithCheckOption

func (v *View) WithCheckOption(option CheckOption) *View

WithCheckOption adds WITH [LOCAL|CASCADED] CHECK OPTION.

type Volatility

type Volatility string

Volatility is a PostgreSQL function volatility category.

const (
	Volatile  Volatility = "VOLATILE"
	Stable    Volatility = "STABLE"
	Immutable Volatility = "IMMUTABLE"
)

Jump to

Keyboard shortcuts

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