Documentation ¶
Index ¶
- Constants
- Variables
- func CastJSONToNumeric(f string) string
- func CastJSONToText(f string) string
- type Adapter
- func (a Adapter) GetLatestHeight(ctx context.Context) (height int64, err error)
- func (a Adapter) GetType() string
- func (a Adapter) Init(ctx context.Context) error
- func (a Adapter) Query(ctx context.Context, q query.Query) (query.Cursor, error)
- func (a Adapter) QueryEvents(ctx context.Context, q query.EventQuery) ([]query.Event, error)
- func (a Adapter) Save(ctx context.Context, txs []cosmosclient.TX) error
- func (a Adapter) UpdateSchema(ctx context.Context, s Schemas) error
- type Filter
- type FilterOption
- type Modifier
- type Option
- type Schemas
- type SchemasWalkFunc
- type ScriptBuilder
- type SliceFilter
Constants ¶
const ( FieldEventAttrName = "attribute.name" FieldEventAttrValue = "attribute.value" FieldEventTXHash = "event.tx_hash" FieldEventType = "event.type" )
const ( DefaultPort = 5432 DefaultHost = "127.0.0.1" )
const SchemasDir = "schemas"
SchemasDir defines the name for the embedded schema directory.
Variables ¶
var ( ErrUnknownEntity = errors.New("unknown query entity") ErrInvalidSortOrder = errors.New("invalid query sort order") )
var ErrClosed = errors.New("no database connection")
ErrClosed is returned when database connection is not open.
Functions ¶
func CastJSONToNumeric ¶
CastJSONToNumeric modifier casts a JSON/JSONB field to numeric.
func CastJSONToText ¶
CastJSONToText modifier casts a JSON/JSONB field to text.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements a data backend adapter for PostgreSQL.
func NewAdapter ¶
NewAdapter creates a new PostgreSQL adapter.
func (Adapter) GetLatestHeight ¶
func (Adapter) QueryEvents ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter defines a generic equality filter.
func FilterByEventAttrName ¶
FilterByEventAttrName creates a new filter to match events by attribute name.
func FilterByEventAttrValue ¶
FilterByEventAttrValue creates a new filter to match events by attribute value.
func FilterByEventAttrValueInt ¶
FilterByEventAttrValueInt creates a new filter to match events by attribute value.
func FilterByEventType ¶
FilterByEventType creates a new filter to match events by type.
type FilterOption ¶
type FilterOption func(*Filter)
FilterOption defines an option for filters.
func WithModifiers ¶
func WithModifiers(m ...Modifier) FilterOption
WithModifiers assigns one or more field modifier functions to the filter. Field modifiers can be used to change the behavior of a filtered field.
type Option ¶
type Option func(*Adapter)
Option defines an option for the adapter.
func WithParams ¶
WithParams configures extra database parameters.
func WithPassword ¶
WithPassword configures a database password.
type Schemas ¶
type Schemas struct {
// contains filtered or unexported fields
}
Schemas defines a type to manage versioning of embedded SQL schemas. Each schema file must live inside the embedded schemas directory and the name of each schema file must be numeric, where the number represents the version.
func NewSchemas ¶
NewSchemas creates a new embedded SQL schema manager. The embedded FS is used to iterate the schema files. By default, the applied schema versions are stored in the "schema" table but the name can have a prefix namespace when different packages are storing the schemas in the same database.
func (Schemas) GetSchemaVersionSQL ¶
GetSchemaVersionSQL returns the SQL query to get the current schema version.
func (Schemas) GetTableDDL ¶
GetTableDDL returns the DDL to create the schemas table.
type SchemasWalkFunc ¶
SchemasWalkFunc is the type of the function called by WalkFrom.
type ScriptBuilder ¶
type ScriptBuilder struct {
// contains filtered or unexported fields
}
ScriptBuilder builds database DDL/SQL scripts that execute multiple commands.
func (*ScriptBuilder) AppendCommand ¶
func (b *ScriptBuilder) AppendCommand(cmd string)
AppendCommand appends a command to the script.
func (*ScriptBuilder) AppendScript ¶
func (b *ScriptBuilder) AppendScript(s []byte)
AppendScript appends a database DDL/SQL script.
func (*ScriptBuilder) BeginTX ¶
func (b *ScriptBuilder) BeginTX()
BeginTX appends a command to start a database transaction.
func (*ScriptBuilder) Bytes ¶
func (b *ScriptBuilder) Bytes() []byte
Bytes returns the whole script as bytes.
func (*ScriptBuilder) CommitTX ¶
func (b *ScriptBuilder) CommitTX()
CommitTX appends a command to commit a database transaction.
type SliceFilter ¶
type SliceFilter struct {
Filter
}
SliceFilter defines a generic slice/array equality filter.
func FilterByEventTXs ¶
func FilterByEventTXs(hashes ...string) SliceFilter
FilterByEventTXs creates a new filter to match events by TX hashes.
func NewIntSliceFilter ¶
func NewIntSliceFilter(field string, values []int64) SliceFilter
NewIntSliceFilter creates a new int64 slice equality filter.
func NewStringSliceFilter ¶
func NewStringSliceFilter(field string, values []string) SliceFilter
NewStringSliceFilter creates a new string slice equality filter.
func (SliceFilter) String ¶
func (f SliceFilter) String() string
func (SliceFilter) Value ¶
func (f SliceFilter) Value() any