edgedb

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TxConflict indicates that the server could not complete a transaction
	// because it encountered a deadlock or serialization error.
	TxConflict = iota

	// NetworkError indicates that the transaction was interupted
	// by a network error.
	NetworkError
)

The following conditions can be configured with a custom RetryRule. See RetryOptions.

Variables

This section is empty.

Functions

func ProtocolVersion

func ProtocolVersion(
	ctx context.Context,
	c *Client,
) (internal.ProtocolVersion, error)

ProtocolVersion returns the protocol version used by c.

func TestClientProtocolVersion

func TestClientProtocolVersion() internal.ProtocolVersion

TestClientProtocolVersion returns the protocol version used to connect to the test server.

Types

type Aspect

type Aspect uint8

Aspect is the description aspect from protocol version 0.X

const (
	DataDescription Aspect = 0x54
)

Aspects

func (Aspect) String

func (i Aspect) String() string

type Cardinality

type Cardinality uint8

Cardinality is the result cardinality for a command.

const (
	NoResult   Cardinality = 0x6e
	AtMostOne  Cardinality = 0x6f
	One        Cardinality = 0x41
	Many       Cardinality = 0x6d
	AtLeastOne Cardinality = 0x4d
)

Cardinalities

func (Cardinality) String

func (i Cardinality) String() string

type Client

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

Client is a connection pool and is safe for concurrent use.

func CreateClient

func CreateClient(ctx context.Context, opts Options) (*Client, error)

CreateClient returns a new client. The client connects lazily. Call Client.EnsureConnected() to force a connection.

func CreateClientDSN

func CreateClientDSN(_ context.Context, dsn string, opts Options) (*Client, error)

CreateClientDSN returns a new client. See also CreateClient.

dsn is either an instance name https://www.edgedb.com/docs/clients/connection or it specifies a single string in the following format:

edgedb://user:password@host:port/database?option=value.

The following options are recognized: host, port, user, database, password.

func TestClient

func TestClient() *Client

TestClient returns a client connected to the test server.

func (*Client) Close

func (p *Client) Close() error

Close closes all connections in the pool. Calling close blocks until all acquired connections have been released, and returns an error if called more than once.

func (*Client) EnsureConnected

func (p *Client) EnsureConnected(ctx context.Context) error

EnsureConnected forces the client to connect if it hasn't already.

func (*Client) Execute

func (p *Client) Execute(
	ctx context.Context,
	cmd string,
	args ...interface{},
) error

Execute an EdgeQL command (or commands).

func (*Client) Query

func (p *Client) Query(
	ctx context.Context,
	cmd string,
	out interface{},
	args ...interface{},
) error

Query runs a query and returns the results.

func (*Client) QueryJSON

func (p *Client) QueryJSON(
	ctx context.Context,
	cmd string,
	out *[]byte,
	args ...interface{},
) error

QueryJSON runs a query and return the results as JSON.

func (*Client) QuerySingle

func (p *Client) QuerySingle(
	ctx context.Context,
	cmd string,
	out interface{},
	args ...interface{},
) error

QuerySingle runs a singleton-returning query and returns its element. If the query executes successfully but doesn't return a result a NoDataError is returned. If the out argument is an optional type the out argument will be set to missing instead of returning a NoDataError.

func (*Client) QuerySingleJSON

func (p *Client) QuerySingleJSON(
	ctx context.Context,
	cmd string,
	out interface{},
	args ...interface{},
) error

QuerySingleJSON runs a singleton-returning query. If the query executes successfully but doesn't have a result a NoDataError is returned.

func (*Client) Tx

func (p *Client) Tx(ctx context.Context, action TxBlock) error

Tx runs an action in a transaction retrying failed actions if they might succeed on a subsequent attempt.

Retries are governed by retry rules. The default rule can be set with WithRetryRule(). For more fine grained control a retry rule can be set for each defined RetryCondition using WithRetryCondition(). When a transaction fails but is retryable the rule for the failure condition is used to determine if the transaction should be tried again based on RetryRule.Attempts and the amount of time to wait before retrying is determined by RetryRule.Backoff. If either field is unset (see RetryRule) then the default rule is used. If the object's default is unset the fall back is 3 attempts and exponential backoff.

func (Client) WithConfig

func (p Client) WithConfig(
	cfg map[string]interface{},
) *Client

WithConfig sets configuration values for the returned client.

func (Client) WithGlobals

func (p Client) WithGlobals(
	globals map[string]interface{},
) *Client

WithGlobals sets values for global variables for the returned client.

func (Client) WithModuleAliases

func (p Client) WithModuleAliases(
	aliases ...ModuleAlias,
) *Client

WithModuleAliases sets module name aliases for the returned client.

func (Client) WithRetryOptions

func (p Client) WithRetryOptions(
	opts RetryOptions,
) *Client

WithRetryOptions returns a shallow copy of the client with the RetryOptions set to opts.

func (Client) WithTxOptions

func (p Client) WithTxOptions(opts TxOptions) *Client

WithTxOptions returns a shallow copy of the client with the TxOptions set to opts.

func (Client) WithoutConfig

func (p Client) WithoutConfig(key ...string) *Client

WithoutConfig unsets configuration values for the returned client.

func (Client) WithoutGlobals

func (p Client) WithoutGlobals(globals ...string) *Client

WithoutGlobals unsets values for global variables for the returned client.

func (Client) WithoutModuleAliases

func (p Client) WithoutModuleAliases(
	aliases ...string,
) *Client

WithoutModuleAliases unsets module name aliases for the returned client.

type CommandDescription

type CommandDescription struct {
	In   descriptor.Descriptor
	Out  descriptor.Descriptor
	Card Cardinality
}

CommandDescription is the information returned in the CommandDataDescription message

func Describe

func Describe(
	ctx context.Context,
	c *Client,
	cmd string,
) (*CommandDescription, error)

Describe returns CommandDescription for the provided cmd.

type CommandDescriptionV2 added in v0.14.1

type CommandDescriptionV2 struct {
	In   descriptor.V2
	Out  descriptor.V2
	Card Cardinality
}

CommandDescriptionV2 is the information returned in the CommandDataDescription message

func DescribeV2 added in v0.14.1

func DescribeV2(
	ctx context.Context,
	c *Client,
	cmd string,
) (*CommandDescriptionV2, error)

DescribeV2 returns CommandDescription for the provided cmd.

type Error

type Error interface {
	Error() string
	Unwrap() error

	// HasTag returns true if the error is marked with the supplied tag.
	HasTag(ErrorTag) bool

	// Category returns true if the error is in the provided category.
	Category(ErrorCategory) bool
}

Error is the error type returned from edgedb.

type ErrorCategory

type ErrorCategory string

ErrorCategory values represent EdgeDB's error types.

const (
	InternalServerError                    ErrorCategory = "errors::InternalServerError"
	UnsupportedFeatureError                ErrorCategory = "errors::UnsupportedFeatureError"
	ProtocolError                          ErrorCategory = "errors::ProtocolError"
	BinaryProtocolError                    ErrorCategory = "errors::BinaryProtocolError"
	UnsupportedProtocolVersionError        ErrorCategory = "errors::UnsupportedProtocolVersionError"
	TypeSpecNotFoundError                  ErrorCategory = "errors::TypeSpecNotFoundError"
	UnexpectedMessageError                 ErrorCategory = "errors::UnexpectedMessageError"
	InputDataError                         ErrorCategory = "errors::InputDataError"
	ParameterTypeMismatchError             ErrorCategory = "errors::ParameterTypeMismatchError"
	StateMismatchError                     ErrorCategory = "errors::StateMismatchError"
	ResultCardinalityMismatchError         ErrorCategory = "errors::ResultCardinalityMismatchError"
	CapabilityError                        ErrorCategory = "errors::CapabilityError"
	UnsupportedCapabilityError             ErrorCategory = "errors::UnsupportedCapabilityError"
	DisabledCapabilityError                ErrorCategory = "errors::DisabledCapabilityError"
	QueryError                             ErrorCategory = "errors::QueryError"
	InvalidSyntaxError                     ErrorCategory = "errors::InvalidSyntaxError"
	EdgeQLSyntaxError                      ErrorCategory = "errors::EdgeQLSyntaxError"
	SchemaSyntaxError                      ErrorCategory = "errors::SchemaSyntaxError"
	GraphQLSyntaxError                     ErrorCategory = "errors::GraphQLSyntaxError"
	InvalidTypeError                       ErrorCategory = "errors::InvalidTypeError"
	InvalidTargetError                     ErrorCategory = "errors::InvalidTargetError"
	InvalidLinkTargetError                 ErrorCategory = "errors::InvalidLinkTargetError"
	InvalidPropertyTargetError             ErrorCategory = "errors::InvalidPropertyTargetError"
	InvalidReferenceError                  ErrorCategory = "errors::InvalidReferenceError"
	UnknownModuleError                     ErrorCategory = "errors::UnknownModuleError"
	UnknownLinkError                       ErrorCategory = "errors::UnknownLinkError"
	UnknownPropertyError                   ErrorCategory = "errors::UnknownPropertyError"
	UnknownUserError                       ErrorCategory = "errors::UnknownUserError"
	UnknownDatabaseError                   ErrorCategory = "errors::UnknownDatabaseError"
	UnknownParameterError                  ErrorCategory = "errors::UnknownParameterError"
	SchemaError                            ErrorCategory = "errors::SchemaError"
	SchemaDefinitionError                  ErrorCategory = "errors::SchemaDefinitionError"
	InvalidDefinitionError                 ErrorCategory = "errors::InvalidDefinitionError"
	InvalidModuleDefinitionError           ErrorCategory = "errors::InvalidModuleDefinitionError"
	InvalidLinkDefinitionError             ErrorCategory = "errors::InvalidLinkDefinitionError"
	InvalidPropertyDefinitionError         ErrorCategory = "errors::InvalidPropertyDefinitionError"
	InvalidUserDefinitionError             ErrorCategory = "errors::InvalidUserDefinitionError"
	InvalidDatabaseDefinitionError         ErrorCategory = "errors::InvalidDatabaseDefinitionError"
	InvalidOperatorDefinitionError         ErrorCategory = "errors::InvalidOperatorDefinitionError"
	InvalidAliasDefinitionError            ErrorCategory = "errors::InvalidAliasDefinitionError"
	InvalidFunctionDefinitionError         ErrorCategory = "errors::InvalidFunctionDefinitionError"
	InvalidConstraintDefinitionError       ErrorCategory = "errors::InvalidConstraintDefinitionError"
	InvalidCastDefinitionError             ErrorCategory = "errors::InvalidCastDefinitionError"
	DuplicateDefinitionError               ErrorCategory = "errors::DuplicateDefinitionError"
	DuplicateModuleDefinitionError         ErrorCategory = "errors::DuplicateModuleDefinitionError"
	DuplicateLinkDefinitionError           ErrorCategory = "errors::DuplicateLinkDefinitionError"
	DuplicatePropertyDefinitionError       ErrorCategory = "errors::DuplicatePropertyDefinitionError"
	DuplicateUserDefinitionError           ErrorCategory = "errors::DuplicateUserDefinitionError"
	DuplicateDatabaseDefinitionError       ErrorCategory = "errors::DuplicateDatabaseDefinitionError"
	DuplicateOperatorDefinitionError       ErrorCategory = "errors::DuplicateOperatorDefinitionError"
	DuplicateViewDefinitionError           ErrorCategory = "errors::DuplicateViewDefinitionError"
	DuplicateFunctionDefinitionError       ErrorCategory = "errors::DuplicateFunctionDefinitionError"
	DuplicateConstraintDefinitionError     ErrorCategory = "errors::DuplicateConstraintDefinitionError"
	DuplicateCastDefinitionError           ErrorCategory = "errors::DuplicateCastDefinitionError"
	DuplicateMigrationError                ErrorCategory = "errors::DuplicateMigrationError"
	SessionTimeoutError                    ErrorCategory = "errors::SessionTimeoutError"
	IdleSessionTimeoutError                ErrorCategory = "errors::IdleSessionTimeoutError"
	QueryTimeoutError                      ErrorCategory = "errors::QueryTimeoutError"
	TransactionTimeoutError                ErrorCategory = "errors::TransactionTimeoutError"
	IdleTransactionTimeoutError            ErrorCategory = "errors::IdleTransactionTimeoutError"
	ExecutionError                         ErrorCategory = "errors::ExecutionError"
	InvalidValueError                      ErrorCategory = "errors::InvalidValueError"
	DivisionByZeroError                    ErrorCategory = "errors::DivisionByZeroError"
	NumericOutOfRangeError                 ErrorCategory = "errors::NumericOutOfRangeError"
	AccessPolicyError                      ErrorCategory = "errors::AccessPolicyError"
	QueryAssertionError                    ErrorCategory = "errors::QueryAssertionError"
	IntegrityError                         ErrorCategory = "errors::IntegrityError"
	ConstraintViolationError               ErrorCategory = "errors::ConstraintViolationError"
	CardinalityViolationError              ErrorCategory = "errors::CardinalityViolationError"
	MissingRequiredError                   ErrorCategory = "errors::MissingRequiredError"
	TransactionError                       ErrorCategory = "errors::TransactionError"
	TransactionConflictError               ErrorCategory = "errors::TransactionConflictError"
	TransactionSerializationError          ErrorCategory = "errors::TransactionSerializationError"
	TransactionDeadlockError               ErrorCategory = "errors::TransactionDeadlockError"
	WatchError                             ErrorCategory = "errors::WatchError"
	ConfigurationError                     ErrorCategory = "errors::ConfigurationError"
	AccessError                            ErrorCategory = "errors::AccessError"
	AuthenticationError                    ErrorCategory = "errors::AuthenticationError"
	AvailabilityError                      ErrorCategory = "errors::AvailabilityError"
	BackendUnavailableError                ErrorCategory = "errors::BackendUnavailableError"
	BackendError                           ErrorCategory = "errors::BackendError"
	UnsupportedBackendFeatureError         ErrorCategory = "errors::UnsupportedBackendFeatureError"
	ClientError                            ErrorCategory = "errors::ClientError"
	ClientConnectionError                  ErrorCategory = "errors::ClientConnectionError"
	ClientConnectionFailedError            ErrorCategory = "errors::ClientConnectionFailedError"
	ClientConnectionFailedTemporarilyError ErrorCategory = "errors::ClientConnectionFailedTemporarilyError"
	ClientConnectionTimeoutError           ErrorCategory = "errors::ClientConnectionTimeoutError"
	ClientConnectionClosedError            ErrorCategory = "errors::ClientConnectionClosedError"
	InterfaceError                         ErrorCategory = "errors::InterfaceError"
	QueryArgumentError                     ErrorCategory = "errors::QueryArgumentError"
	MissingArgumentError                   ErrorCategory = "errors::MissingArgumentError"
	UnknownArgumentError                   ErrorCategory = "errors::UnknownArgumentError"
	InvalidArgumentError                   ErrorCategory = "errors::InvalidArgumentError"
	NoDataError                            ErrorCategory = "errors::NoDataError"
	InternalClientError                    ErrorCategory = "errors::InternalClientError"
)

type ErrorTag

type ErrorTag string

ErrorTag is the argument type to Error.HasTag().

const (
	ShouldRetry     ErrorTag = "SHOULD_RETRY"
	ShouldReconnect ErrorTag = "SHOULD_RECONNECT"
)

type Executor added in v0.16.0

type Executor interface {
	Execute(context.Context, string, ...any) error
	Query(context.Context, string, any, ...any) error
	QueryJSON(context.Context, string, *[]byte, ...any) error
	QuerySingle(context.Context, string, any, ...any) error
	QuerySingleJSON(context.Context, string, any, ...any) error
}

Executor is a common interface between *Client and *Tx, that can run queries on an EdgeDB database.

type Format

type Format uint8

Format is the query response format.

const (
	Binary       Format = 0x62
	JSON         Format = 0x6a
	JSONElements Format = 0x4a
	Null         Format = 0x6e
)

IO Formats

func (Format) String

func (i Format) String() string

type IsolationLevel

type IsolationLevel string

IsolationLevel documentation can be found here https://www.edgedb.com/docs/reference/edgeql/tx_start#parameters

const (
	// Serializable is the only isolation level
	Serializable IsolationLevel = "serializable"
)

type Message

type Message uint8

Message is a protocol message type.

const (
	Authentication         Message = 0x52
	CommandComplete        Message = 0x43
	CommandDataDescription Message = 0x54
	Data                   Message = 0x44
	DumpBlock              Message = 0x3d
	DumpHeader             Message = 0x40
	ErrorResponse          Message = 0x45
	LogMessage             Message = 0x4c
	ParameterStatus        Message = 0x53
	ParseComplete          Message = 0x31
	ReadyForCommand        Message = 0x5a
	RestoreReady           Message = 0x2b
	ServerHandshake        Message = 0x76
	ServerKeyData          Message = 0x4b
	StateDataDescription   Message = 0x73
)

Message types sent by server

const (
	AuthenticationSASLInitialResponse Message = 0x70
	AuthenticationSASLResponse        Message = 0x72
	ClientHandshake                   Message = 0x56
	DescribeStatement                 Message = 0x44
	Dump                              Message = 0x3e
	Execute0pX                        Message = 0x45
	ExecuteScript                     Message = 0x51
	Flush                             Message = 0x48
	Execute                           Message = 0x4f
	Parse                             Message = 0x50
	Restore                           Message = 0x3c
	RestoreBlock                      Message = 0x3d
	RestoreEOF                        Message = 0x2e
	Sync                              Message = 0x53
	Terminate                         Message = 0x58
)

Message types sent by client

type ModuleAlias

type ModuleAlias struct {
	Alias  string
	Module string
}

ModuleAlias is an alias name and module name pair.

type Options

type Options struct {
	// Host is an EdgeDB server host address, given as either an IP address or
	// domain name. (Unix-domain socket paths are not supported)
	//
	// Host cannot be specified alongside the 'dsn' argument, or
	// CredentialsFile option. Host will override all other credentials
	// resolved from any environment variables, or project credentials with
	// their defaults.
	Host string

	// Port is a port number to connect to at the server host.
	//
	// Port cannot be specified alongside the 'dsn' argument, or
	// CredentialsFile option. Port will override all other credentials
	// resolved from any environment variables, or project credentials with
	// their defaults.
	Port int

	// Credentials is a JSON string containing connection credentials.
	//
	// Credentials cannot be specified alongside the 'dsn' argument, Host,
	// Port, or CredentialsFile.  Credentials will override all other
	// credentials not present in the credentials string with their defaults.
	Credentials []byte

	// CredentialsFile is a path to a file containing connection credentials.
	//
	// CredentialsFile cannot be specified alongside the 'dsn' argument, Host,
	// Port, or Credentials.  CredentialsFile will override all other
	// credentials not present in the credentials file with their defaults.
	CredentialsFile string

	// User is the name of the database role used for authentication.
	//
	// If not specified, the value is resolved from any compound
	// argument/option, then from EDGEDB_USER, then any compound environment
	// variable, then project credentials.
	User string

	// Database is the name of the database to connect to.
	//
	// If not specified, the value is resolved from any compound
	// argument/option, then from EDGEDB_DATABASE, then any compound
	// environment variable, then project credentials.
	Database string

	// Branch is the name of the branch to use.
	//
	// If not specified, the value is resolved from any compound
	// argument/option, then from EDGEDB_BRANCH, then any compound environment
	// variable, then project credentials.
	Branch string

	// Password to be used for authentication, if the server requires one.
	//
	// If not specified, the value is resolved from any compound
	// argument/option, then from EDGEDB_PASSWORD, then any compound
	// environment variable, then project credentials.
	// Note that the use of the environment variable is discouraged
	// as other users and applications may be able to read it
	// without needing specific privileges.
	Password types.OptionalStr

	// ConnectTimeout is used when establishing connections in the background.
	ConnectTimeout time.Duration

	// WaitUntilAvailable determines how long to wait
	// to reestablish a connection.
	WaitUntilAvailable time.Duration

	// Concurrency determines the maximum number of connections.
	// If Concurrency is zero, max(4, runtime.NumCPU()) will be used.
	// Has no effect for single connections.
	Concurrency uint

	// Parameters used to configure TLS connections to EdgeDB server.
	TLSOptions TLSOptions

	// Read the TLS certificate from this file.
	// DEPRECATED, use TLSOptions.CAFile instead.
	TLSCAFile string

	// Specifies how strict TLS validation is.
	// DEPRECATED, use TLSOptions.SecurityMode instead.
	TLSSecurity string

	// ServerSettings is currently unused.
	ServerSettings map[string][]byte

	// SecretKey is used to connect to cloud instances.
	SecretKey string
}

Options for connecting to an EdgeDB server

func TestClientOptions

func TestClientOptions() Options

TestClientOptions returns the Options used to connect to the test server.

type RetryBackoff

type RetryBackoff func(n int) time.Duration

RetryBackoff returns the duration to wait after the nth attempt before making the next attempt when retrying a transaction.

type RetryCondition

type RetryCondition int

RetryCondition represents scenarios that can cause a transaction run in Tx() methods to be retried.

type RetryOptions

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

RetryOptions configures how Tx() retries failed transactions. Use NewRetryOptions to get a default RetryOptions value instead of creating one yourself.

func NewRetryOptions added in v0.15.0

func NewRetryOptions() RetryOptions

NewRetryOptions returns the default retry options.

func (RetryOptions) WithCondition

func (o RetryOptions) WithCondition(
	condition RetryCondition,
	rule RetryRule,
) RetryOptions

WithCondition sets the retry rule for the specified condition.

func (RetryOptions) WithDefault

func (o RetryOptions) WithDefault(rule RetryRule) RetryOptions

WithDefault sets the rule for all conditions to rule.

type RetryRule

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

RetryRule determines how transactions should be retried when run in Tx() methods. See Client.Tx() for details.

func NewRetryRule

func NewRetryRule() RetryRule

NewRetryRule returns the default RetryRule value.

func (RetryRule) WithAttempts

func (r RetryRule) WithAttempts(attempts int) RetryRule

WithAttempts sets the rule's attempts. attempts must be greater than zero.

func (RetryRule) WithBackoff

func (r RetryRule) WithBackoff(fn RetryBackoff) RetryRule

WithBackoff returns a copy of the RetryRule with backoff set to fn.

type TLSOptions

type TLSOptions struct {
	// PEM-encoded CA certificate
	CA []byte
	// Path to a PEM-encoded CA certificate file
	CAFile string
	// Determines how strict we are with TLS checks
	SecurityMode TLSSecurityMode
	// Used to verify the hostname on the returned certificates
	ServerName string
}

TLSOptions contains the parameters needed to configure TLS on EdgeDB server connections.

type TLSSecurityMode

type TLSSecurityMode string

TLSSecurityMode specifies how strict TLS validation is.

const (
	// TLSModeDefault makes security mode inferred from other options
	TLSModeDefault TLSSecurityMode = "default"
	// TLSModeInsecure results in no certificate verification whatsoever
	TLSModeInsecure TLSSecurityMode = "insecure"
	// TLSModeNoHostVerification enables certificate verification
	// against CAs, but hostname matching is not performed.
	TLSModeNoHostVerification TLSSecurityMode = "no_host_verification"
	// TLSModeStrict enables full certificate and hostname verification.
	TLSModeStrict TLSSecurityMode = "strict"
)

type Tx

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

Tx is a transaction. Use Client.Tx() to get a transaction.

func (*Tx) Execute

func (t *Tx) Execute(
	ctx context.Context,
	cmd string,
	args ...interface{},
) error

Execute an EdgeQL command (or commands).

func (*Tx) Query

func (t *Tx) Query(
	ctx context.Context,
	cmd string,
	out interface{},
	args ...interface{},
) error

Query runs a query and returns the results.

func (*Tx) QueryJSON

func (t *Tx) QueryJSON(
	ctx context.Context,
	cmd string,
	out *[]byte,
	args ...interface{},
) error

QueryJSON runs a query and return the results as JSON.

func (*Tx) QuerySingle

func (t *Tx) QuerySingle(
	ctx context.Context,
	cmd string,
	out interface{},
	args ...interface{},
) error

QuerySingle runs a singleton-returning query and returns its element. If the query executes successfully but doesn't return a result a NoDataError is returned. If the out argument is an optional type the out argument will be set to missing instead of returning a NoDataError.

func (*Tx) QuerySingleJSON

func (t *Tx) QuerySingleJSON(
	ctx context.Context,
	cmd string,
	out interface{},
	args ...interface{},
) error

QuerySingleJSON runs a singleton-returning query. If the query executes successfully but doesn't have a result a NoDataError is returned.

type TxBlock

type TxBlock func(context.Context, *Tx) error

TxBlock is work to be done in a transaction.

type TxOptions

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

TxOptions configures how transactions behave.

func NewTxOptions

func NewTxOptions() TxOptions

NewTxOptions returns the default TxOptions value.

func (TxOptions) WithDeferrable

func (o TxOptions) WithDeferrable(d bool) TxOptions

WithDeferrable returns a shallow copy of the client with the transaction deferrable mode set to d.

func (TxOptions) WithIsolation

func (o TxOptions) WithIsolation(i IsolationLevel) TxOptions

WithIsolation returns a copy of the TxOptions with the isolation level set to i.

func (TxOptions) WithReadOnly

func (o TxOptions) WithReadOnly(r bool) TxOptions

WithReadOnly returns a shallow copy of the client with the transaction read only access mode set to r.

Jump to

Keyboard shortcuts

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