queries

package
v0.0.0-...-e0217b8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 3 Imported by: 0

README

Expected workflow

  1. Add a SQL query/statement in queries.sql, following the other examples.
  2. Run make sqlc using the same version of sqlc as in build/Dockerfile.codegen

sqlc decides what the return-type of the generated method should be based on the :exec suffix (documentation here):

  • :exec will only tell you whether the query succeeded: error
  • :execrows will tell you how many rows were affected: (int64, error)
  • :one will give you back a single struct: (Author, error)
  • :many will give you back a slice of structs: ([]Author, error)

It is configured by the sqlc.yaml file. You can read docs about the various options it supports here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetCheckConstraintsRow

type GetCheckConstraintsRow struct {
	Oid                  interface{}
	ConstraintName       string
	ColumnNames          []string
	TableName            string
	TableSchemaName      string
	IsValid              bool
	IsNotInheritable     bool
	ConstraintExpression string
}

type GetColumnsForTableRow

type GetColumnsForTableRow struct {
	ColumnName          string
	CollationName       string
	CollationSchemaName string
	DefaultValue        string
	IsNotNull           bool
	ColumnSize          int16
	IdentityType        string
	StartValue          sql.NullInt64
	IncrementValue      sql.NullInt64
	MaxValue            sql.NullInt64
	MinValue            sql.NullInt64
	CacheSize           sql.NullInt64
	IsCycle             sql.NullBool
	ColumnType          string
}

type GetDependsOnFunctionsParams

type GetDependsOnFunctionsParams struct {
	SystemCatalog interface{}
	ObjectID      interface{}
}

type GetDependsOnFunctionsRow

type GetDependsOnFunctionsRow struct {
	FuncName              string
	FuncSchemaName        string
	FuncIdentityArguments string
}

type GetEnumsRow

type GetEnumsRow struct {
	EnumName       string
	EnumSchemaName string
	EnumLabels     []string
}

type GetExtensionsRow

type GetExtensionsRow struct {
	Oid              interface{}
	ExtensionName    string
	ExtensionVersion string
	SchemaName       string
}

type GetForeignKeyConstraintsRow

type GetForeignKeyConstraintsRow struct {
	ConstraintName         string
	OwningTableName        string
	OwningTableSchemaName  string
	ForeignTableName       string
	ForeignTableSchemaName string
	IsValid                bool
	ConstraintDef          string
}

type GetFunctionsRow

type GetFunctionsRow struct {
	Oid                   interface{}
	FuncName              string
	FuncSchemaName        string
	FuncLang              string
	FuncIdentityArguments string
	FuncDef               string
}

type GetIndexesRow

type GetIndexesRow struct {
	Oid                   interface{}
	IndexName             string
	TableName             string
	TableSchemaName       string
	DefStmt               string
	ConstraintName        string
	ConstraintType        string
	ConstraintDef         string
	IndexIsValid          bool
	IndexIsPk             bool
	IndexIsUnique         bool
	ParentIndexName       string
	ParentIndexSchemaName string
	ColumnNames           []string
	ConstraintIsLocal     bool
}

type GetPoliciesRow

type GetPoliciesRow struct {
	PolicyName            string
	OwningTableName       string
	OwningTableSchemaName string
	IsPermissive          bool
	AppliesTo             []string
	Cmd                   string
	CheckExpression       string
	UsingExpression       string
	ColumnNames           []string
}

type GetSequencesRow

type GetSequencesRow struct {
	SequenceName       string
	SequenceSchemaName string
	OwnerColumnName    string
	OwnerSchemaName    string
	OwnerTableName     string
	StartValue         int64
	IncrementValue     int64
	MaxValue           int64
	MinValue           int64
	CacheSize          int64
	IsCycle            bool
	DataType           string
}

type GetTablesRow

type GetTablesRow struct {
	Oid                   interface{}
	TableName             string
	TableSchemaName       string
	ReplicaIdentity       string
	RlsEnabled            bool
	RlsForced             bool
	ParentTableName       string
	ParentTableSchemaName string
	PartitionKeyDef       string
	PartitionForValues    string
}

type GetTriggersRow

type GetTriggersRow struct {
	TriggerName           string
	OwningTableName       string
	OwningTableSchemaName string
	FuncName              string
	FuncSchemaName        string
	FuncIdentityArguments string
	TriggerDef            string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetCheckConstraints

func (q *Queries) GetCheckConstraints(ctx context.Context) ([]GetCheckConstraintsRow, error)

func (*Queries) GetColumnsForTable

func (q *Queries) GetColumnsForTable(ctx context.Context, attrelid interface{}) ([]GetColumnsForTableRow, error)

func (*Queries) GetDependsOnFunctions

func (q *Queries) GetDependsOnFunctions(ctx context.Context, arg GetDependsOnFunctionsParams) ([]GetDependsOnFunctionsRow, error)

func (*Queries) GetEnums

func (q *Queries) GetEnums(ctx context.Context) ([]GetEnumsRow, error)

func (*Queries) GetExtensions

func (q *Queries) GetExtensions(ctx context.Context) ([]GetExtensionsRow, error)

func (*Queries) GetForeignKeyConstraints

func (q *Queries) GetForeignKeyConstraints(ctx context.Context) ([]GetForeignKeyConstraintsRow, error)

func (*Queries) GetFunctions

func (q *Queries) GetFunctions(ctx context.Context) ([]GetFunctionsRow, error)

func (*Queries) GetIndexes

func (q *Queries) GetIndexes(ctx context.Context) ([]GetIndexesRow, error)

func (*Queries) GetPolicies

func (q *Queries) GetPolicies(ctx context.Context) ([]GetPoliciesRow, error)

func (*Queries) GetSchemas

func (q *Queries) GetSchemas(ctx context.Context) ([]string, error)

func (*Queries) GetSequences

func (q *Queries) GetSequences(ctx context.Context) ([]GetSequencesRow, error)

func (*Queries) GetTables

func (q *Queries) GetTables(ctx context.Context) ([]GetTablesRow, error)

func (*Queries) GetTriggers

func (q *Queries) GetTriggers(ctx context.Context) ([]GetTriggersRow, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

Jump to

Keyboard shortcuts

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