Documentation ¶
Index ¶
- Constants
- func CheckDatabase(dbConfig *Config) (bool, error)
- func CleanStressTest()
- func ContextWithDbConn(parent context.Context, db *Database, conn *DbConn) context.Context
- func CreateRecords(ctx context.Context, table string, records []Record, filters Filters) ([]byte, int64, error)
- func Delete(ctx context.Context, table string, filters Filters) ([]byte, int64, error)
- func DeleteColumn(ctx context.Context, tablename string, name string, cascade bool) error
- func DeleteConstraint(ctx context.Context, tablename string, name string) error
- func DeleteFunction(ctx context.Context, name string) error
- func DeletePolicy(ctx context.Context, table string, name string) error
- func DeletePrivilege(ctx context.Context, privilege *Privilege) error
- func DeleteRecords(ctx context.Context, table string, filters Filters) ([]byte, int64, error)
- func DeleteRole(ctx context.Context, name string) error
- func DeleteSchema(ctx context.Context, name string, cascade bool) error
- func DeleteTable(ctx context.Context, name string, ifExists bool) error
- func DeleteUser(ctx context.Context, name string) error
- func DeleteView(ctx context.Context, name string) error
- func ExecFunction(ctx context.Context, fname string, record Record, filters Filters, ...) ([]byte, int64, error)
- func Execute(ctx context.Context, function string, record Record, filters Filters, ...) ([]byte, int64, error)
- func FillContext(ctx context.Context, r *http.Request, db *Database, conn *DbConn, role string) context.Context
- func GetDbRole(ctx context.Context) string
- func GetDynStructures(ctx context.Context, query string) ([]any, error)
- func GetMaps(ctx context.Context, query string) ([]map[string]any, error)
- func GetRecords(ctx context.Context, table string, filters Filters) ([]byte, int64, error)
- func HasTX(c *DbPoolConn) bool
- func Insert(ctx context.Context, table string, records []Record, filters Filters) ([]byte, int64, error)
- func IsExist(err error) bool
- func PrepareConnection(ctx context.Context, conn *DbPoolConn, role string, claims string, ...) error
- func PrepareDatabase(adminURL string, dbConfig *Config) error
- func PrepareStressTest(conn *pgxpool.Conn)
- func QueryExec(ctx context.Context, query string, values ...any) error
- func QueryStructure[T any](ctx context.Context, query string, values ...any) (*T, error)
- func QueryStructures[T any](ctx context.Context, query string, values ...any) ([]T, error)
- func ReleaseConn(ctx context.Context, conn *DbPoolConn) error
- func ReleaseConnection(ctx context.Context, conn *DbPoolConn, httpErr bool, resetRole bool) error
- func Select(ctx context.Context, table string, filters Filters) ([]byte, int64, error)
- func SetQueryBuilder(ctx context.Context, qb QueryBuilder)
- func SetRequestParser(ctx context.Context, rp RequestParser)
- func StressTest()
- func Update(ctx context.Context, table string, record Record, filters Filters) ([]byte, int64, error)
- func UpdateColumn(ctx context.Context, tablename string, name string, column *ColumnUpdate) error
- func UpdateRecords(ctx context.Context, table string, record Record, filters Filters) ([]byte, int64, error)
- func UpdateRole(ctx context.Context, name string, role *RoleUpdate) error
- func UpdateSchema(ctx context.Context, name string, schema *SchemaUpdate) error
- func UpdateTable(ctx context.Context, name string, table *TableUpdate) error
- type Argument
- type BinarySerializer
- type BuildError
- type BuildStack
- type CSVSerializer
- type Column
- type ColumnType
- type ColumnUpdate
- type CommonBuilder
- func (CommonBuilder) BuildDelete(table string, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (delete string, valueList []any, err error)
- func (CommonBuilder) BuildExecute(name string, record Record, parts *QueryParts, options *QueryOptions, ...) (query string, valueList []any, err error)
- func (CommonBuilder) BuildInsert(table string, records []Record, parts *QueryParts, options *QueryOptions, ...) (insert string, valueList []any, err error)
- func (CommonBuilder) BuildUpdate(table string, record Record, parts *QueryParts, options *QueryOptions, ...) (update string, valueList []any, err error)
- type Config
- type Constraint
- type ContentTypeError
- type CustomRows
- func (cr *CustomRows) Close()
- func (cr *CustomRows) CommandTag() pgconn.CommandTag
- func (cr *CustomRows) Conn() *pgx.Conn
- func (cr *CustomRows) Err() error
- func (cr *CustomRows) FieldDescriptions() []pgconn.FieldDescription
- func (cr *CustomRows) Next() bool
- func (cr *CustomRows) RawValues() [][]byte
- func (cr *CustomRows) Scan(dest ...any) error
- func (cr *CustomRows) Values() ([]any, error)
- type Database
- type DatabaseInfo
- type DatabaseJSONSerializer
- type DatabaseUpdate
- type DbConn
- type DbEngine
- func (dbe *DbEngine) AcquireConnection(ctx context.Context) (*pgxpool.Conn, error)
- func (dbe *DbEngine) CloneDatabase(ctx context.Context, name string, source string, force bool) (*DatabaseInfo, error)
- func (dbe *DbEngine) Close()
- func (dbe *DbEngine) CreateActiveDatabase(ctx context.Context, name string, owner string) (*Database, error)
- func (dbe *DbEngine) CreateDatabase(ctx context.Context, name string, owner string, getIfExists bool) (*DatabaseInfo, error)
- func (dbe *DbEngine) DeleteDatabase(ctx context.Context, name string) error
- func (dbe *DbEngine) GetActiveDatabase(ctx context.Context, name string) (db *Database, err error)
- func (dbe *DbEngine) GetDatabase(ctx context.Context, name string) (*DatabaseInfo, error)
- func (dbe *DbEngine) GetDatabases(ctx context.Context) ([]DatabaseInfo, error)
- func (dbe *DbEngine) GetMainDatabase(ctx context.Context) (*Database, error)
- func (dbe *DbEngine) GetOrCreateActiveDatabase(ctx context.Context, name string) (*Database, error)
- func (dbe *DbEngine) IsDatabaseAllowed(name string) bool
- func (dbe *DbEngine) UpdateDatabase(ctx context.Context, name string, update *DatabaseUpdate) error
- type DbLogger
- type DbPoolConn
- type DirectQueryBuilder
- type Field
- type Filters
- type ForeignKey
- type Function
- type JSONSerializer
- type Join
- type OrderField
- type ParseError
- type Policy
- type PostgRestParser
- type PostgresConfig
- type Privilege
- type QueryBuilder
- type QueryOptions
- type QueryParts
- type QueryWithJSON
- type RangeError
- type Record
- type RelType
- type Relationship
- type Request
- type RequestParser
- type Role
- type RoleUpdate
- type Schema
- type SchemaInfo
- func (si *SchemaInfo) FindRelationshipByCol(ftable, col string) *Relationship
- func (si *SchemaInfo) GetColumnType(ftable string, column string) *ColumnType
- func (si *SchemaInfo) GetForeignKeys(ftable string) []ForeignKey
- func (si *SchemaInfo) GetFunction(name string) *Function
- func (si *SchemaInfo) GetPrimaryKey(ftable string) *Constraint
- func (si *SchemaInfo) GetRelationships(ftable string) []Relationship
- func (si *SchemaInfo) GetTable(ftable string) *Table
- func (si *SchemaInfo) GetTypeById(id uint32) *Type
- type SchemaUpdate
- type SelectField
- type SelectRelation
- type SerializeError
- type SmoothContext
- type Table
- type TableUpdate
- type TextBuilder
- type TextSerializer
- type Type
- type User
- type View
- type WhereConditionNode
Constants ¶
const DEFAULT_ANON = "anon"
const (
SMOOTHDB = "smoothdb"
)
Variables ¶
This section is empty.
Functions ¶
func CheckDatabase ¶ added in v0.2.3
func CleanStressTest ¶
func CleanStressTest()
func ContextWithDbConn ¶
ContextWithDb creates a context using a specific connection
func CreateRecords ¶ added in v0.2.0
func DeleteColumn ¶ added in v0.1.2
func DeleteConstraint ¶ added in v0.1.2
func DeleteRecords ¶ added in v0.2.0
func DeleteTable ¶ added in v0.1.2
func ExecFunction ¶ added in v0.2.0
func FillContext ¶
func FillContext(ctx context.Context, r *http.Request, db *Database, conn *DbConn, role string) context.Context
FillContext compiles and inserts the information related to the database, cresting a new derived context
func GetDynStructures ¶ added in v0.2.4
func GetRecords ¶ added in v0.2.0
func HasTX ¶
func HasTX(c *DbPoolConn) bool
func PrepareConnection ¶
func PrepareConnection(ctx context.Context, conn *DbPoolConn, role string, claims string, newAcquire bool) error
PrepareConnection starts a transaction if the configuration requires it, i.e. if TransactionMode is not equal to 'none'. If the role parameter is not empty, it binds the role to the connection.
func PrepareDatabase ¶ added in v0.2.3
PrepareDatabase prepares the database for SmoothDb
func PrepareStressTest ¶
func QueryStructure ¶ added in v0.2.4
func QueryStructures ¶ added in v0.2.4
func ReleaseConn ¶
func ReleaseConn(ctx context.Context, conn *DbPoolConn) error
ReleaseConn releases a connection to the proper pool. It is a simplified version of ReleaseConnection
func ReleaseConnection ¶
ReleaseConnection releases a connection to the proper pool. It resets its role if requested and closes the transaction, based on the configuration.
func SetQueryBuilder ¶
func SetQueryBuilder(ctx context.Context, qb QueryBuilder)
SetQueryBuilder allows changing the query builder in the current context
func SetRequestParser ¶
func SetRequestParser(ctx context.Context, rp RequestParser)
SetRequestParser allows changing the request parser in the current context
func StressTest ¶
func StressTest()
func UpdateColumn ¶ added in v0.1.2
func UpdateRecords ¶ added in v0.2.0
func UpdateRole ¶ added in v0.2.7
func UpdateRole(ctx context.Context, name string, role *RoleUpdate) error
func UpdateSchema ¶ added in v0.2.7
func UpdateSchema(ctx context.Context, name string, schema *SchemaUpdate) error
func UpdateTable ¶ added in v0.1.2
func UpdateTable(ctx context.Context, name string, table *TableUpdate) error
Types ¶
type BinarySerializer ¶ added in v0.2.6
func (*BinarySerializer) Serialize ¶ added in v0.2.6
func (b *BinarySerializer) Serialize(rows pgx.Rows, scalar bool, single bool, info *SchemaInfo) ([]byte, int64, error)
type BuildError ¶
type BuildError struct {
// contains filtered or unexported fields
}
func (BuildError) Error ¶
func (e BuildError) Error() string
type BuildStack ¶
type BuildStack struct {
// contains filtered or unexported fields
}
BuildStack represents the context when navigating the AST produced by the parser
type CSVSerializer ¶ added in v0.2.5
type CSVSerializer struct {
TextBuilder
}
func (*CSVSerializer) Serialize ¶ added in v0.2.5
func (csv *CSVSerializer) Serialize(rows pgx.Rows, scalar bool, single bool, info *SchemaInfo) ([]byte, int64, error)
type Column ¶
type Column struct { Name string `json:"name"` Type string `json:"type"` NotNull bool `json:"notnull"` Default *string `json:"default"` Constraints []string `json:"constraints"` Table string `json:"table,omitempty"` Schema string `json:"schema,omitempty"` }
func CreateColumn ¶ added in v0.1.2
type ColumnType ¶
type ColumnType struct { Table string `json:"table"` Schema string `json:"schema"` Name string `json:"name"` Type string `json:"type"` DataType string `json:"datatype"` IsArray bool `json:"isarray"` IsComposite bool `json:"iscomposite"` }
func GetColumnTypes ¶ added in v0.1.2
func GetColumnTypes(ctx context.Context) ([]ColumnType, error)
type ColumnUpdate ¶
type CommonBuilder ¶
type CommonBuilder struct{}
func (CommonBuilder) BuildDelete ¶
func (CommonBuilder) BuildDelete(table string, parts *QueryParts, options *QueryOptions, info *SchemaInfo) ( delete string, valueList []any, err error)
func (CommonBuilder) BuildExecute ¶
func (CommonBuilder) BuildExecute(name string, record Record, parts *QueryParts, options *QueryOptions, info *SchemaInfo) ( query string, valueList []any, err error)
func (CommonBuilder) BuildInsert ¶
func (CommonBuilder) BuildInsert(table string, records []Record, parts *QueryParts, options *QueryOptions, info *SchemaInfo) ( insert string, valueList []any, err error)
func (CommonBuilder) BuildUpdate ¶
func (CommonBuilder) BuildUpdate(table string, record Record, parts *QueryParts, options *QueryOptions, info *SchemaInfo) ( update string, valueList []any, err error)
type Config ¶
type Config struct { URL string `comment:"Database URL"` MinPoolConnections int32 `comment:"Miminum connections per pool (default: 10)"` MaxPoolConnections int32 `comment:"Maximum connections per pool (default: 100)"` AnonRole string `comment:"Anonymous role (default: '' for no anon)"` AllowedDatabases []string `comment:"Allowed databases (default: [] for all)"` SchemaSearchPath []string `comment:"Schema search path (default: [] for Postgres search path)"` TransactionMode string `` /* 137-byte string literal not displayed */ }
func DefaultConfig ¶
func DefaultConfig() *Config
type Constraint ¶
type Constraint struct { Name string `json:"name"` Type string `json:"type"` // check, unique, primary, foreign Table string `json:"table"` Schema string `json:"schema"` Columns []string `json:"columns"` RelatedTable *string `json:"reltable"` RelatedSchema *string `json:"relschema"` RelatedColumns []string `json:"relcolumns"` Definition string `json:"definition"` }
func CreateConstraint ¶ added in v0.1.2
func CreateConstraint(ctx context.Context, constraint *Constraint) (*Constraint, error)
func GetConstraints ¶ added in v0.1.2
func GetConstraints(ctx context.Context, tablename string) ([]Constraint, error)
type ContentTypeError ¶ added in v0.2.5
type ContentTypeError struct {
// contains filtered or unexported fields
}
func (ContentTypeError) Error ¶ added in v0.2.5
func (e ContentTypeError) Error() string
type CustomRows ¶ added in v0.2.0
type CustomRows struct { FieldDescriptions_ []pgconn.FieldDescription RawValues_ [][][]byte CurrentRow int }
CustomRows is used for testing, to be able to do more iterations on a single query result. This is not permitted by pgx.Rows.
func CopyRows ¶ added in v0.2.0
func CopyRows(rows pgx.Rows) (*CustomRows, error)
func (*CustomRows) Close ¶ added in v0.2.0
func (cr *CustomRows) Close()
func (*CustomRows) CommandTag ¶ added in v0.2.0
func (cr *CustomRows) CommandTag() pgconn.CommandTag
func (*CustomRows) Conn ¶ added in v0.2.0
func (cr *CustomRows) Conn() *pgx.Conn
func (*CustomRows) Err ¶ added in v0.2.0
func (cr *CustomRows) Err() error
func (*CustomRows) FieldDescriptions ¶ added in v0.2.0
func (cr *CustomRows) FieldDescriptions() []pgconn.FieldDescription
func (*CustomRows) Next ¶ added in v0.2.0
func (cr *CustomRows) Next() bool
func (*CustomRows) RawValues ¶ added in v0.2.0
func (cr *CustomRows) RawValues() [][]byte
func (*CustomRows) Scan ¶ added in v0.2.0
func (cr *CustomRows) Scan(dest ...any) error
func (*CustomRows) Values ¶ added in v0.2.0
func (cr *CustomRows) Values() ([]any, error)
type Database ¶
type Database struct { DatabaseInfo // contains filtered or unexported fields }
func (*Database) AcquireConnection ¶
type DatabaseInfo ¶
type DatabaseJSONSerializer ¶
type DatabaseJSONSerializer struct{}
func (DatabaseJSONSerializer) Serialize ¶
func (DatabaseJSONSerializer) Serialize(rows pgx.Rows, scalar bool, single bool, info *SchemaInfo) ([]byte, int64, error)
type DatabaseUpdate ¶ added in v0.2.7
type DbConn ¶
type DbConn = pgx.Conn
type DbEngine ¶
type DbEngine struct {
// contains filtered or unexported fields
}
DbEngine represents the database engine (the PostgreSQL instance or "cluster")
func InitDbEngine ¶
InitDbEngine creates a connection pool, connects to the engine and initializes it
func (*DbEngine) AcquireConnection ¶
AcquireConnection acquires a connection in the database engine
func (*DbEngine) CloneDatabase ¶ added in v0.2.3
func (dbe *DbEngine) CloneDatabase(ctx context.Context, name string, source string, force bool) (*DatabaseInfo, error)
CloneDatabase creates a new database cloning a source db. The force parameter can be used to stop all the connections to the source db, which is a prerequisite.
func (*DbEngine) Close ¶
func (dbe *DbEngine) Close()
Close closes the database engine and all of its active databases
func (*DbEngine) CreateActiveDatabase ¶
func (dbe *DbEngine) CreateActiveDatabase(ctx context.Context, name string, owner string) (*Database, error)
CreateActiveDatabase allows to create a database and ensures it is activated
func (*DbEngine) CreateDatabase ¶
func (dbe *DbEngine) CreateDatabase(ctx context.Context, name string, owner string, getIfExists bool) (*DatabaseInfo, error)
CreateDatabase creates a new database Use CreateActiveDatabase to create an active instance of a database
func (*DbEngine) DeleteDatabase ¶
DeleteDatabase deletes a database. It blocks until all connections are returned to pool.
func (*DbEngine) GetActiveDatabase ¶
GetActiveDatabase allows to get a database and ensures it is activated (eg it has a connection pool and its cached information)
func (*DbEngine) GetDatabase ¶
GetDatabase gets information about a database. Use GetActiveDatabase to get an active instance of a database
func (*DbEngine) GetDatabases ¶
func (dbe *DbEngine) GetDatabases(ctx context.Context) ([]DatabaseInfo, error)
GetDatabases lists the available databases, filtering the not-managed ones
func (*DbEngine) GetMainDatabase ¶ added in v0.2.4
GetMainDatabase is used to get the main db
func (*DbEngine) GetOrCreateActiveDatabase ¶ added in v0.2.3
GetOrCreateActiveDatabase allows to get or create a database and ensures it is activated
func (*DbEngine) IsDatabaseAllowed ¶
IsDatabaseAllowed checks if a database can be managed by smoothdb
func (*DbEngine) UpdateDatabase ¶ added in v0.2.7
UpdateDatabase updates a database.
type DbLogger ¶
type DbLogger struct {
// contains filtered or unexported fields
}
func NewDbLogger ¶
NewDbLogger accepts a zerolog.Logger as input and returns a new custom pgx logging facade as output.
type DbPoolConn ¶
func AcquireConnection ¶
func AcquireConnection(ctx context.Context, db *Database) (conn *DbPoolConn, err error)
AcquireConnection takes a connection from a database pool. If the db parameter is nil, it uses the main db pool.
func ContextWithDb ¶
func ContextWithDb(parent context.Context, db *Database, role string) (context.Context, *DbPoolConn, error)
ContextWithDb creates a context and gets a connection to the requested database, with a specific role. The db parameter can be nil, to indicate the main database. It is used to start a communication with a database, both internally and from code using smoothdb as a library.
type DirectQueryBuilder ¶
type DirectQueryBuilder struct {
CommonBuilder
}
func (DirectQueryBuilder) BuildSelect ¶
func (DirectQueryBuilder) BuildSelect(table string, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error)
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a column and its attributes in the different parts of a query: select, where, order, etc clauses
type ForeignKey ¶
type Function ¶
type Function struct { Name string `json:"name"` Schema string `json:"schema"` Arguments []Argument `json:"arguments"` Returns string `json:"returns"` Language string `json:"language"` Definition string `json:"definition"` ReturnTypeId uint32 `json:"rettypeid"` ReturnIsSet bool `json:"retisset"` HasUnnamed bool `json:"hasunnamed"` // has unnamed parameters HasOut bool `json:"hasout"` // has OUT, INOUT, TABLE parameters IsVariadic bool `json:"isvariadic"` }
func CreateFunction ¶ added in v0.2.0
type JSONSerializer ¶ added in v0.2.5
type JSONSerializer struct {
TextBuilder
}
func (*JSONSerializer) Serialize ¶ added in v0.2.5
func (j *JSONSerializer) Serialize(rows pgx.Rows, scalar bool, single bool, info *SchemaInfo) ([]byte, int64, error)
type Join ¶
type Join struct {
// contains filtered or unexported fields
}
Join containts information to create a join relationship. It is composed while building the select clause.
type OrderField ¶
type OrderField struct {
// contains filtered or unexported fields
}
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
func (ParseError) Error ¶
func (e ParseError) Error() string
type Policy ¶
type PostgRestParser ¶
type PostgRestParser struct {
// contains filtered or unexported fields
}
type PostgresConfig ¶ added in v0.2.3
type PostgresConfig struct { Host string // host (e.g. localhost) or absolute path to unix domain socket directory (e.g. /private/tmp) Port uint16 Database string User string Password string }
func ParsePostgresURL ¶ added in v0.2.3
func ParsePostgresURL(url string) (*PostgresConfig, error)
type Privilege ¶
type Privilege struct { TargetName string `json:"targetname"` TargetSchema string `json:"targetschema,omitempty"` TargetType string `json:"targettype"` // database, schema, table, column, function Columns []string `json:"columns,omitempty"` // to insert column privileges Types []string `json:"types"` Grantee string `json:"grantee"` Grantor string `json:"grantor"` ACL string `json:"acl"` }
func CreatePrivilege ¶
func GetDatabasePrivileges ¶
type QueryBuilder ¶
type QueryBuilder interface { BuildSelect(table string, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error) BuildInsert(table string, records []Record, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error) BuildUpdate(table string, record Record, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error) BuildDelete(table string, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error) BuildExecute(table string, record Record, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error) // contains filtered or unexported methods }
type QueryOptions ¶
type QueryOptions struct { Schema string ContentType string // json, csv ReturnRepresentation bool MergeDuplicates bool IgnoreDuplicates bool ParamsAsSingleObject bool TxCommit bool TxRollback bool Singular bool HasRange bool RangeMin int64 RangeMax int64 Count string // exact, planned, estimated }
func GetQueryOptions ¶ added in v0.2.7
func GetQueryOptions(ctx context.Context) *QueryOptions
GetQueryOptions gets the query options from the current context
type QueryParts ¶
type QueryParts struct {
// contains filtered or unexported fields
}
QueryParts is the root of the AST produced by the request parser
type QueryWithJSON ¶
type QueryWithJSON struct {
CommonBuilder
}
func (QueryWithJSON) BuildSelect ¶
func (QueryWithJSON) BuildSelect(table string, parts *QueryParts, options *QueryOptions, info *SchemaInfo) (string, []any, error)
type RangeError ¶ added in v0.2.4
type RangeError struct {
// contains filtered or unexported fields
}
func (RangeError) Error ¶ added in v0.2.4
func (e RangeError) Error() string
type Relationship ¶
type RequestParser ¶
type RequestParser interface {
// contains filtered or unexported methods
}
RequestParser is the interface used to parse the query string in the request and extract the significant headers. Initially we will support PostgREST mode and later perhaps others (Django?).
type Role ¶
type Role struct { Name string `json:"name"` IsSuperUser bool `json:"issuperuser"` CanLogin bool `json:"canlogin"` NoInheritPrivileges bool `json:"noinherit"` CanCreateRoles bool `json:"cancreateroles"` CanCreateDatabases bool `json:"cancreatedatabases"` CanBypassRLS bool `json:"canbypassrls"` MemberOf []string `json:"memberof"` // readonly for now }
type RoleUpdate ¶ added in v0.2.7
type RoleUpdate struct { Name *string `json:"name"` IsSuperUser *bool `json:"issuperuser"` CanLogin *bool `json:"canlogin"` NoInheritPrivileges *bool `json:"noinherit"` CanCreateRoles *bool `json:"cancreateroles"` CanCreateDatabases *bool `json:"cancreatedatabases"` CanBypassRLS *bool `json:"canbypassrls"` }
type SchemaInfo ¶
type SchemaInfo struct {
// contains filtered or unexported fields
}
func NewSchemaInfo ¶
func NewSchemaInfo(ctx context.Context, db *Database) (*SchemaInfo, error)
func (*SchemaInfo) FindRelationshipByCol ¶
func (si *SchemaInfo) FindRelationshipByCol(ftable, col string) *Relationship
func (*SchemaInfo) GetColumnType ¶
func (si *SchemaInfo) GetColumnType(ftable string, column string) *ColumnType
func (*SchemaInfo) GetForeignKeys ¶
func (si *SchemaInfo) GetForeignKeys(ftable string) []ForeignKey
func (*SchemaInfo) GetFunction ¶
func (si *SchemaInfo) GetFunction(name string) *Function
func (*SchemaInfo) GetPrimaryKey ¶
func (si *SchemaInfo) GetPrimaryKey(ftable string) *Constraint
func (*SchemaInfo) GetRelationships ¶
func (si *SchemaInfo) GetRelationships(ftable string) []Relationship
func (*SchemaInfo) GetTable ¶
func (si *SchemaInfo) GetTable(ftable string) *Table
func (*SchemaInfo) GetTypeById ¶
func (si *SchemaInfo) GetTypeById(id uint32) *Type
type SchemaUpdate ¶ added in v0.2.7
type SelectField ¶
type SelectField struct {
// contains filtered or unexported fields
}
SelectField can contain a selected field or a relationship with another table. For example, select=id,name,other(name) will produce:
- a SelectField with field.name = "id"
- a SelectField with field.name = "name"
- a SelectField with an empty field and a SelectRelation with relation.name = "other", itself with a SelectField in relation.fields with field.name = "name".
label is used as an alias both for a field and a relation.
type SelectRelation ¶
type SelectRelation struct {
// contains filtered or unexported fields
}
SelectRelation stores information about a relationship, expressed in the select clause like: /table?select=id,name,other1(name),...other2(id)
type SerializeError ¶
type SerializeError struct {
// contains filtered or unexported fields
}
func (SerializeError) Error ¶
func (e SerializeError) Error() string
type SmoothContext ¶
type SmoothContext struct { Db *Database Conn *DbConn Role string RequestParser RequestParser QueryBuilder QueryBuilder QueryOptions *QueryOptions }
SmoothContext contains all the information needed to perform database commands as well as configured parser and query builder
func GetSmoothContext ¶
func GetSmoothContext(ctx context.Context) *SmoothContext
GetSmoothContext gets SmoothContext from the standard context
type Table ¶
type Table struct { Name string `json:"name"` Schema string `json:"schema"` Owner string `json:"owner"` RowSecurity bool `json:"rowsecurity"` Columns []Column `json:"columns,omitempty"` Constraints []string `json:"constraints"` Inherits string `json:"inherit,omitempty"` IfNotExists bool `json:"ifnotexists,omitempty"` HasIndexes bool `json:"hasindexes"` HasTriggers bool `json:"hastriggers"` IsPartition bool `json:"ispartition"` }
func CreateTable ¶ added in v0.1.2
type TableUpdate ¶
type TextBuilder ¶ added in v0.2.5
type TextSerializer ¶ added in v0.2.5
type Type ¶
type Type struct { Id uint32 `json:"id"` Name string `json:"name"` Schema string `json:"schema"` IsArray bool `json:"isarray"` IsRange bool `json:"isrange"` IsComposite bool `json:"iscomposite"` IsTable bool `json:"istable"` IsEnum bool `json:"isenum"` IsDomain bool `json:"isdomain"` ArraySubType uint32 `json:"arraysubtype"` RangeSubType *uint32 `json:"rangesubtype"` DomainSubType string `json:"domainsubtype"` SubTypeIds []uint32 `json:"subtypeids"` SubTypeNames []string `json:"subtypenames"` }
type User ¶
type View ¶
type WhereConditionNode ¶
type WhereConditionNode struct {
// contains filtered or unexported fields
}
Source Files ¶
- columns.go
- config.go
- conn.go
- constraints.go
- content_type.go
- context.go
- database.go
- db_log.go
- db_types.go
- dbengine.go
- errors.go
- functions.go
- grants.go
- init_config.go
- mapserializer.go
- policies.go
- querybuilder.go
- queryexecutor.go
- records.go
- requestparser.go
- roles.go
- schemainfo.go
- schemas.go
- stress.go
- structserializer.go
- tables.go
- textserializer.go
- types.go
- users.go
- utils.go
- views.go