Documentation ¶
Overview ¶
Package edgedb is the official Go driver for EdgeDB. Additionally, github.com/edgedb/edgedb-go/cmd/edgeql-go is a code generator that generates go functions from edgeql files.
Typical client usage looks like this:
package main import ( "context" "log" "github.com/edgedb/edgedb-go" ) func main() { ctx := context.Background() client, err := edgedb.CreateClient(ctx, edgedb.Options{}) if err != nil { log.Fatal(err) } defer client.Close() var ( age int64 = 21 users []struct { ID edgedb.UUID `edgedb:"id"` Name string `edgedb:"name"` } ) query := "SELECT User{name} FILTER .age = <int64>$0" err = client.Query(ctx, query, &users, age) ... }
We recommend using environment variables for connection parameters. See the client connection docs for more information.
You may also connect to a database using a DSN:
url := "edgedb://edgedb@localhost/edgedb" client, err := edgedb.CreateClientDSN(ctx, url, opts)
Or you can use Option fields.
opts := edgedb.Options{ Database: "edgedb", User: "edgedb", Concurrency: 4, } client, err := edgedb.CreateClient(ctx, opts)
Errors ¶
edgedb never returns underlying errors directly. If you are checking for things like context expiration use errors.Is() or errors.As().
err := client.Query(...) if errors.Is(err, context.Canceled) { ... }
Most errors returned by the edgedb package will satisfy the edgedb.Error interface which has methods for introspecting.
err := client.Query(...) var edbErr edgedb.Error if errors.As(err, &edbErr) && edbErr.Category(edgedb.NoDataError){ ... }
Datatypes ¶
The following list shows the marshal/unmarshal mapping between EdgeDB types and go types:
EdgeDB Go --------- --------- Set []anytype array<anytype> []anytype tuple struct named tuple struct Object struct bool bool, edgedb.OptionalBool bytes []byte, edgedb.OptionalBytes str string, edgedb.OptionalStr anyenum string, edgedb.OptionalStr datetime time.Time, edgedb.OptionalDateTime cal::local_datetime edgedb.LocalDateTime, edgedb.OptionalLocalDateTime cal::local_date edgedb.LocalDate, edgedb.OptionalLocalDate cal::local_time edgedb.LocalTime, edgedb.OptionalLocalTime duration edgedb.Duration, edgedb.OptionalDuration cal::relative_duration edgedb.RelativeDuration, edgedb.OptionalRelativeDuration float32 float32, edgedb.OptionalFloat32 float64 float64, edgedb.OptionalFloat64 int16 int16, edgedb.OptionalFloat16 int32 int32, edgedb.OptionalInt16 int64 int64, edgedb.OptionalInt64 uuid edgedb.UUID, edgedb.OptionalUUID json []byte, edgedb.OptionalBytes bigint *big.Int, edgedb.OptionalBigInt decimal user defined (see Custom Marshalers)
Note that EdgeDB's std::duration type is represented in int64 microseconds while go's time.Duration type is int64 nanoseconds. It is incorrect to cast one directly to the other.
Shape fields that are not required must use optional types for receiving query results. The edgedb.Optional struct can be embedded to make structs optional.
type User struct { edgedb.Optional Email string `edgedb:"email"` } var result User err := client.QuerySingle(ctx, `SELECT User { email } LIMIT 0`, $result) fmt.Println(result.Missing()) // Output: true err := client.QuerySingle(ctx, `SELECT User { email } LIMIT 1`, $result) fmt.Println(result.Missing()) // Output: false
Not all types listed above are valid query parameters. To pass a slice of scalar values use array in your query. EdgeDB doesn't currently support using sets as parameters.
query := `select User filter .id in array_unpack(<array<uuid>>$1)` client.QuerySingle(ctx, query, $user, []edgedb.UUID{...})
Nested structures are also not directly allowed but you can use json instead.
By default EdgeDB will ignore embedded structs when marshaling/unmarshaling. To treat an embedded struct's fields as part of the parent struct's fields, tag the embedded struct with `edgedb:"$inline"`.
type Object struct { ID edgedb.UUID } type User struct { Object `edgedb:"$inline"` Name string }
Custom Marshalers ¶
Interfaces for user defined marshaler/unmarshalers are documented in the internal/marshal package.
Example ¶
// This source file is part of the EdgeDB open source project. // // Copyright EdgeDB Inc. and the EdgeDB authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package main import ( "context" "fmt" "log" "time" "github.com/edgedb/edgedb-go" ) type User struct { ID edgedb.UUID `edgedb:"id"` Name string `edgedb:"name"` DOB time.Time `edgedb:"dob"` } func main() { opts := edgedb.Options{Concurrency: 4} ctx := context.Background() db, err := edgedb.CreateClientDSN(ctx, "edgedb://edgedb@localhost/test", opts) if err != nil { log.Fatal(err) } defer db.Close() // create a user object type. err = db.Execute(ctx, ` CREATE TYPE User { CREATE REQUIRED PROPERTY name -> str; CREATE PROPERTY dob -> datetime; } `) if err != nil { log.Fatal(err) } // Insert a new user. var inserted struct{ id edgedb.UUID } err = db.QuerySingle(ctx, ` INSERT User { name := <str>$0, dob := <datetime>$1 } `, &inserted, "Bob", time.Date(1984, 3, 1, 0, 0, 0, 0, time.UTC)) if err != nil { log.Fatal(err) } // Select users. var users []User args := map[string]interface{}{"name": "Bob"} query := "SELECT User {name, dob} FILTER .name = <str>$name" err = db.Query(ctx, query, &users, args) if err != nil { log.Fatal(err) } fmt.Println(users) }
Output:
Example (LinkProperty) ¶
Link properties are treated as fields in the linked to struct, and the @ is omitted from the field's tag.
package main import ( "context" edgedb "github.com/edgedb/edgedb-go" ) var ( ctx context.Context client *edgedb.Client ) func main() { var result []struct { Name string `edgedb:"name"` Friends []struct { Name string `edgedb:"name"` Strength edgedb.OptionalFloat64 `edgedb:"strength"` } `edgedb:"friends"` } _ = client.Query( ctx, `select Person { name, friends: { name, @strength, } }`, &result, ) }
Output:
Index ¶
- Constants
- Variables
- type Client
- type DateDuration
- type Duration
- type Error
- type ErrorCategory
- type ErrorTag
- type Executor
- type IsolationLevel
- type LocalDate
- type LocalDateTime
- type LocalTime
- type Memory
- type ModuleAlias
- type Optional
- type OptionalBigInt
- type OptionalBool
- type OptionalBytes
- type OptionalDateDuration
- type OptionalDateTime
- type OptionalDuration
- type OptionalFloat32
- type OptionalFloat64
- type OptionalInt16
- type OptionalInt32
- type OptionalInt64
- type OptionalLocalDate
- type OptionalLocalDateTime
- type OptionalLocalTime
- type OptionalMemory
- type OptionalRangeDateTime
- type OptionalRangeFloat32
- type OptionalRangeFloat64
- type OptionalRangeInt32
- type OptionalRangeInt64
- type OptionalRangeLocalDate
- type OptionalRangeLocalDateTime
- type OptionalRelativeDuration
- type OptionalStr
- type OptionalUUID
- type Options
- type RangeDateTime
- type RangeFloat32
- type RangeFloat64
- type RangeInt32
- type RangeInt64
- type RangeLocalDate
- type RangeLocalDateTime
- type RelativeDuration
- type RetryBackoff
- type RetryCondition
- type RetryOptions
- type RetryRule
- type TLSOptions
- type TLSSecurityMode
- type Tx
- type TxBlock
- type TxOptions
- type UUID
Examples ¶
Constants ¶
const ( InternalServerError = edgedb.InternalServerError UnsupportedFeatureError = edgedb.UnsupportedFeatureError ProtocolError = edgedb.ProtocolError BinaryProtocolError = edgedb.BinaryProtocolError UnsupportedProtocolVersionError = edgedb.UnsupportedProtocolVersionError TypeSpecNotFoundError = edgedb.TypeSpecNotFoundError UnexpectedMessageError = edgedb.UnexpectedMessageError InputDataError = edgedb.InputDataError ParameterTypeMismatchError = edgedb.ParameterTypeMismatchError StateMismatchError = edgedb.StateMismatchError ResultCardinalityMismatchError = edgedb.ResultCardinalityMismatchError CapabilityError = edgedb.CapabilityError UnsupportedCapabilityError = edgedb.UnsupportedCapabilityError DisabledCapabilityError = edgedb.DisabledCapabilityError QueryError = edgedb.QueryError InvalidSyntaxError = edgedb.InvalidSyntaxError EdgeQLSyntaxError = edgedb.EdgeQLSyntaxError SchemaSyntaxError = edgedb.SchemaSyntaxError GraphQLSyntaxError = edgedb.GraphQLSyntaxError InvalidTypeError = edgedb.InvalidTypeError InvalidTargetError = edgedb.InvalidTargetError InvalidLinkTargetError = edgedb.InvalidLinkTargetError InvalidPropertyTargetError = edgedb.InvalidPropertyTargetError InvalidReferenceError = edgedb.InvalidReferenceError UnknownModuleError = edgedb.UnknownModuleError UnknownLinkError = edgedb.UnknownLinkError UnknownPropertyError = edgedb.UnknownPropertyError UnknownUserError = edgedb.UnknownUserError UnknownDatabaseError = edgedb.UnknownDatabaseError UnknownParameterError = edgedb.UnknownParameterError SchemaError = edgedb.SchemaError SchemaDefinitionError = edgedb.SchemaDefinitionError InvalidDefinitionError = edgedb.InvalidDefinitionError InvalidModuleDefinitionError = edgedb.InvalidModuleDefinitionError InvalidLinkDefinitionError = edgedb.InvalidLinkDefinitionError InvalidPropertyDefinitionError = edgedb.InvalidPropertyDefinitionError InvalidUserDefinitionError = edgedb.InvalidUserDefinitionError InvalidDatabaseDefinitionError = edgedb.InvalidDatabaseDefinitionError InvalidOperatorDefinitionError = edgedb.InvalidOperatorDefinitionError InvalidAliasDefinitionError = edgedb.InvalidAliasDefinitionError InvalidFunctionDefinitionError = edgedb.InvalidFunctionDefinitionError InvalidConstraintDefinitionError = edgedb.InvalidConstraintDefinitionError InvalidCastDefinitionError = edgedb.InvalidCastDefinitionError DuplicateDefinitionError = edgedb.DuplicateDefinitionError DuplicateModuleDefinitionError = edgedb.DuplicateModuleDefinitionError DuplicateLinkDefinitionError = edgedb.DuplicateLinkDefinitionError DuplicatePropertyDefinitionError = edgedb.DuplicatePropertyDefinitionError DuplicateUserDefinitionError = edgedb.DuplicateUserDefinitionError DuplicateDatabaseDefinitionError = edgedb.DuplicateDatabaseDefinitionError DuplicateOperatorDefinitionError = edgedb.DuplicateOperatorDefinitionError DuplicateViewDefinitionError = edgedb.DuplicateViewDefinitionError DuplicateFunctionDefinitionError = edgedb.DuplicateFunctionDefinitionError DuplicateConstraintDefinitionError = edgedb.DuplicateConstraintDefinitionError DuplicateCastDefinitionError = edgedb.DuplicateCastDefinitionError DuplicateMigrationError = edgedb.DuplicateMigrationError SessionTimeoutError = edgedb.SessionTimeoutError IdleSessionTimeoutError = edgedb.IdleSessionTimeoutError QueryTimeoutError = edgedb.QueryTimeoutError TransactionTimeoutError = edgedb.TransactionTimeoutError IdleTransactionTimeoutError = edgedb.IdleTransactionTimeoutError ExecutionError = edgedb.ExecutionError InvalidValueError = edgedb.InvalidValueError DivisionByZeroError = edgedb.DivisionByZeroError NumericOutOfRangeError = edgedb.NumericOutOfRangeError AccessPolicyError = edgedb.AccessPolicyError QueryAssertionError = edgedb.QueryAssertionError IntegrityError = edgedb.IntegrityError ConstraintViolationError = edgedb.ConstraintViolationError CardinalityViolationError = edgedb.CardinalityViolationError MissingRequiredError = edgedb.MissingRequiredError TransactionError = edgedb.TransactionError TransactionConflictError = edgedb.TransactionConflictError TransactionSerializationError = edgedb.TransactionSerializationError TransactionDeadlockError = edgedb.TransactionDeadlockError WatchError = edgedb.WatchError ConfigurationError = edgedb.ConfigurationError AccessError = edgedb.AccessError AuthenticationError = edgedb.AuthenticationError AvailabilityError = edgedb.AvailabilityError BackendError = edgedb.BackendError UnsupportedBackendFeatureError = edgedb.UnsupportedBackendFeatureError ClientError = edgedb.ClientError ClientConnectionError = edgedb.ClientConnectionError ClientConnectionFailedError = edgedb.ClientConnectionFailedError ClientConnectionFailedTemporarilyError = edgedb.ClientConnectionFailedTemporarilyError ClientConnectionTimeoutError = edgedb.ClientConnectionTimeoutError ClientConnectionClosedError = edgedb.ClientConnectionClosedError InterfaceError = edgedb.InterfaceError QueryArgumentError = edgedb.QueryArgumentError MissingArgumentError = edgedb.MissingArgumentError UnknownArgumentError = edgedb.UnknownArgumentError InvalidArgumentError = edgedb.InvalidArgumentError NoDataError = edgedb.NoDataError InternalClientError = edgedb.InternalClientError ShouldRetry = edgedb.ShouldRetry ShouldReconnect = edgedb.ShouldReconnect )
const ( // NetworkError indicates that the transaction was interupted // by a network error. NetworkError = edgedb.NetworkError // Serializable is the only isolation level Serializable = edgedb.Serializable // TLSModeDefault makes security mode inferred from other options TLSModeDefault = edgedb.TLSModeDefault // TLSModeInsecure results in no certificate verification whatsoever TLSModeInsecure = edgedb.TLSModeInsecure // TLSModeNoHostVerification enables certificate verification // against CAs, but hostname matching is not performed. TLSModeNoHostVerification = edgedb.TLSModeNoHostVerification // TLSModeStrict enables full certificate and hostname verification. TLSModeStrict = edgedb.TLSModeStrict // TxConflict indicates that the server could not complete a transaction // because it encountered a deadlock or serialization error. TxConflict = edgedb.TxConflict )
Variables ¶
var ( // CreateClient returns a new client. The client connects lazily. Call // Client.EnsureConnected() to force a connection. CreateClient = edgedb.CreateClient // 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. CreateClientDSN = edgedb.CreateClientDSN // DurationFromNanoseconds creates a Duration represented as microseconds // from a [time.Duration] represented as nanoseconds. DurationFromNanoseconds = edgedbtypes.DurationFromNanoseconds // NewDateDuration returns a new DateDuration NewDateDuration = edgedbtypes.NewDateDuration // NewLocalDate returns a new LocalDate NewLocalDate = edgedbtypes.NewLocalDate // NewLocalDateTime returns a new LocalDateTime NewLocalDateTime = edgedbtypes.NewLocalDateTime // NewLocalTime returns a new LocalTime NewLocalTime = edgedbtypes.NewLocalTime // NewOptionalBigInt is a convenience function for creating an OptionalBigInt // with its value set to v. NewOptionalBigInt = edgedbtypes.NewOptionalBigInt // NewOptionalBool is a convenience function for creating an OptionalBool with // its value set to v. NewOptionalBool = edgedbtypes.NewOptionalBool // NewOptionalBytes is a convenience function for creating an OptionalBytes // with its value set to v. NewOptionalBytes = edgedbtypes.NewOptionalBytes // NewOptionalDateDuration is a convenience function for creating an // OptionalDateDuration with its value set to v. NewOptionalDateDuration = edgedbtypes.NewOptionalDateDuration // NewOptionalDateTime is a convenience function for creating an // OptionalDateTime with its value set to v. NewOptionalDateTime = edgedbtypes.NewOptionalDateTime // NewOptionalDuration is a convenience function for creating an // OptionalDuration with its value set to v. NewOptionalDuration = edgedbtypes.NewOptionalDuration // NewOptionalFloat32 is a convenience function for creating an OptionalFloat32 // with its value set to v. NewOptionalFloat32 = edgedbtypes.NewOptionalFloat32 // NewOptionalFloat64 is a convenience function for creating an OptionalFloat64 // with its value set to v. NewOptionalFloat64 = edgedbtypes.NewOptionalFloat64 // NewOptionalInt16 is a convenience function for creating an OptionalInt16 // with its value set to v. NewOptionalInt16 = edgedbtypes.NewOptionalInt16 // NewOptionalInt32 is a convenience function for creating an OptionalInt32 // with its value set to v. NewOptionalInt32 = edgedbtypes.NewOptionalInt32 // NewOptionalInt64 is a convenience function for creating an OptionalInt64 // with its value set to v. NewOptionalInt64 = edgedbtypes.NewOptionalInt64 // NewOptionalLocalDate is a convenience function for creating an // OptionalLocalDate with its value set to v. NewOptionalLocalDate = edgedbtypes.NewOptionalLocalDate // NewOptionalLocalDateTime is a convenience function for creating an // OptionalLocalDateTime with its value set to v. NewOptionalLocalDateTime = edgedbtypes.NewOptionalLocalDateTime // NewOptionalLocalTime is a convenience function for creating an // OptionalLocalTime with its value set to v. NewOptionalLocalTime = edgedbtypes.NewOptionalLocalTime // NewOptionalMemory is a convenience function for creating an // OptionalMemory with its value set to v. NewOptionalMemory = edgedbtypes.NewOptionalMemory // NewOptionalRangeDateTime is a convenience function for creating an // OptionalRangeDateTime with its value set to v. NewOptionalRangeDateTime = edgedbtypes.NewOptionalRangeDateTime // NewOptionalRangeFloat32 is a convenience function for creating an // OptionalRangeFloat32 with its value set to v. NewOptionalRangeFloat32 = edgedbtypes.NewOptionalRangeFloat32 // NewOptionalRangeFloat64 is a convenience function for creating an // OptionalRangeFloat64 with its value set to v. NewOptionalRangeFloat64 = edgedbtypes.NewOptionalRangeFloat64 // NewOptionalRangeInt32 is a convenience function for creating an // OptionalRangeInt32 with its value set to v. NewOptionalRangeInt32 = edgedbtypes.NewOptionalRangeInt32 // NewOptionalRangeInt64 is a convenience function for creating an // OptionalRangeInt64 with its value set to v. NewOptionalRangeInt64 = edgedbtypes.NewOptionalRangeInt64 // NewOptionalRangeLocalDate is a convenience function for creating an // OptionalRangeLocalDate with its value set to v. NewOptionalRangeLocalDate = edgedbtypes.NewOptionalRangeLocalDate // NewOptionalRangeLocalDateTime is a convenience function for creating an // OptionalRangeLocalDateTime with its value set to v. NewOptionalRangeLocalDateTime = edgedbtypes.NewOptionalRangeLocalDateTime // NewOptionalRelativeDuration is a convenience function for creating an // OptionalRelativeDuration with its value set to v. NewOptionalRelativeDuration = edgedbtypes.NewOptionalRelativeDuration // NewOptionalStr is a convenience function for creating an OptionalStr with // its value set to v. NewOptionalStr = edgedbtypes.NewOptionalStr // NewOptionalUUID is a convenience function for creating an OptionalUUID with // its value set to v. NewOptionalUUID = edgedbtypes.NewOptionalUUID // NewRangeDateTime creates a new RangeDateTime value. NewRangeDateTime = edgedbtypes.NewRangeDateTime // NewRangeFloat32 creates a new RangeFloat32 value. NewRangeFloat32 = edgedbtypes.NewRangeFloat32 // NewRangeFloat64 creates a new RangeFloat64 value. NewRangeFloat64 = edgedbtypes.NewRangeFloat64 // NewRangeInt32 creates a new RangeInt32 value. NewRangeInt32 = edgedbtypes.NewRangeInt32 // NewRangeInt64 creates a new RangeInt64 value. NewRangeInt64 = edgedbtypes.NewRangeInt64 // NewRangeLocalDate creates a new RangeLocalDate value. NewRangeLocalDate = edgedbtypes.NewRangeLocalDate // NewRangeLocalDateTime creates a new RangeLocalDateTime value. NewRangeLocalDateTime = edgedbtypes.NewRangeLocalDateTime // NewRelativeDuration returns a new RelativeDuration NewRelativeDuration = edgedbtypes.NewRelativeDuration // NewRetryOptions returns the default RetryOptions value. NewRetryOptions = edgedb.NewRetryOptions // NewRetryRule returns the default RetryRule value. NewRetryRule = edgedb.NewRetryRule // NewTxOptions returns the default TxOptions value. NewTxOptions = edgedb.NewTxOptions // ParseUUID parses s into a UUID or returns an error. ParseUUID = edgedbtypes.ParseUUID )
Functions ¶
This section is empty.
Types ¶
type DateDuration ¶ added in v0.12.0
type DateDuration = edgedbtypes.DateDuration
DateDuration represents the elapsed time between two dates in a fuzzy human way.
type Duration ¶
type Duration = edgedbtypes.Duration
Duration represents the elapsed time between two instants as an int64 microsecond count.
type ErrorCategory ¶
type ErrorCategory = edgedb.ErrorCategory
ErrorCategory values represent EdgeDB's error types.
type Executor ¶
Executor is a common interface between Client and Tx, that can run queries on an EdgeDB database.
type IsolationLevel ¶ added in v0.6.0
type IsolationLevel = edgedb.IsolationLevel
IsolationLevel documentation can be found here https://www.edgedb.com/docs/reference/edgeql/tx_start#parameters
type LocalDate ¶
type LocalDate = edgedbtypes.LocalDate
LocalDate is a date without a time zone. https://www.edgedb.com/docs/stdlib/datetime#type::cal::local_date
type LocalDateTime ¶
type LocalDateTime = edgedbtypes.LocalDateTime
LocalDateTime is a date and time without timezone. https://www.edgedb.com/docs/stdlib/datetime#type::cal::local_datetime
type LocalTime ¶
type LocalTime = edgedbtypes.LocalTime
LocalTime is a time without a time zone. https://www.edgedb.com/docs/stdlib/datetime#type::cal::local_time
type ModuleAlias ¶ added in v0.11.0
type ModuleAlias = edgedb.ModuleAlias
ModuleAlias is an alias name and module name pair.
type Optional ¶ added in v0.8.0
type Optional = edgedbtypes.Optional
Optional represents a shape field that is not required. Optional is embedded in structs to make them optional. For example:
type User struct { edgedb.Optional Name string `edgedb:"name"` }
type OptionalBigInt ¶ added in v0.8.0
type OptionalBigInt = edgedbtypes.OptionalBigInt
OptionalBigInt is an optional *big.Int. Optional types must be used for out parameters when a shape field is not required.
type OptionalBool ¶ added in v0.7.0
type OptionalBool = edgedbtypes.OptionalBool
OptionalBool is an optional bool. Optional types must be used for out parameters when a shape field is not required.
type OptionalBytes ¶ added in v0.8.0
type OptionalBytes = edgedbtypes.OptionalBytes
OptionalBytes is an optional []byte. Optional types must be used for out parameters when a shape field is not required.
type OptionalDateDuration ¶ added in v0.12.0
type OptionalDateDuration = edgedbtypes.OptionalDateDuration
OptionalDateDuration is an optional DateDuration. Optional types must be used for out parameters when a shape field is not required.
type OptionalDateTime ¶ added in v0.8.0
type OptionalDateTime = edgedbtypes.OptionalDateTime
OptionalDateTime is an optional time.Time. Optional types must be used for out parameters when a shape field is not required.
type OptionalDuration ¶ added in v0.8.0
type OptionalDuration = edgedbtypes.OptionalDuration
OptionalDuration is an optional Duration. Optional types must be used for out parameters when a shape field is not required.
type OptionalFloat32 ¶ added in v0.8.0
type OptionalFloat32 = edgedbtypes.OptionalFloat32
OptionalFloat32 is an optional float32. Optional types must be used for out parameters when a shape field is not required.
type OptionalFloat64 ¶ added in v0.8.0
type OptionalFloat64 = edgedbtypes.OptionalFloat64
OptionalFloat64 is an optional float64. Optional types must be used for out parameters when a shape field is not required.
type OptionalInt16 ¶ added in v0.8.0
type OptionalInt16 = edgedbtypes.OptionalInt16
OptionalInt16 is an optional int16. Optional types must be used for out parameters when a shape field is not required.
type OptionalInt32 ¶ added in v0.8.0
type OptionalInt32 = edgedbtypes.OptionalInt32
OptionalInt32 is an optional int32. Optional types must be used for out parameters when a shape field is not required.
type OptionalInt64 ¶ added in v0.8.0
type OptionalInt64 = edgedbtypes.OptionalInt64
OptionalInt64 is an optional int64. Optional types must be used for out parameters when a shape field is not required.
type OptionalLocalDate ¶ added in v0.8.0
type OptionalLocalDate = edgedbtypes.OptionalLocalDate
OptionalLocalDate is an optional LocalDate. Optional types must be used for out parameters when a shape field is not required.
type OptionalLocalDateTime ¶ added in v0.8.0
type OptionalLocalDateTime = edgedbtypes.OptionalLocalDateTime
OptionalLocalDateTime is an optional LocalDateTime. Optional types must be used for out parameters when a shape field is not required.
type OptionalLocalTime ¶ added in v0.8.0
type OptionalLocalTime = edgedbtypes.OptionalLocalTime
OptionalLocalTime is an optional LocalTime. Optional types must be used for out parameters when a shape field is not required.
type OptionalMemory ¶ added in v0.9.0
type OptionalMemory = edgedbtypes.OptionalMemory
OptionalMemory is an optional Memory. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeDateTime ¶ added in v0.12.0
type OptionalRangeDateTime = edgedbtypes.OptionalRangeDateTime
OptionalRangeDateTime is an optional RangeDateTime. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeFloat32 ¶ added in v0.12.0
type OptionalRangeFloat32 = edgedbtypes.OptionalRangeFloat32
OptionalRangeFloat32 is an optional RangeFloat32. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeFloat64 ¶ added in v0.12.0
type OptionalRangeFloat64 = edgedbtypes.OptionalRangeFloat64
OptionalRangeFloat64 is an optional RangeFloat64. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeInt32 ¶ added in v0.12.0
type OptionalRangeInt32 = edgedbtypes.OptionalRangeInt32
OptionalRangeInt32 is an optional RangeInt32. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeInt64 ¶ added in v0.12.0
type OptionalRangeInt64 = edgedbtypes.OptionalRangeInt64
OptionalRangeInt64 is an optional RangeInt64. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeLocalDate ¶ added in v0.12.0
type OptionalRangeLocalDate = edgedbtypes.OptionalRangeLocalDate
OptionalRangeLocalDate is an optional RangeLocalDate. Optional types must be used for out parameters when a shape field is not required.
type OptionalRangeLocalDateTime ¶ added in v0.12.0
type OptionalRangeLocalDateTime = edgedbtypes.OptionalRangeLocalDateTime
OptionalRangeLocalDateTime is an optional RangeLocalDateTime. Optional types must be used for out parameters when a shape field is not required.
type OptionalRelativeDuration ¶ added in v0.8.0
type OptionalRelativeDuration = edgedbtypes.OptionalRelativeDuration
OptionalRelativeDuration is an optional RelativeDuration. Optional types must be used for out parameters when a shape field is not required.
type OptionalStr ¶ added in v0.8.0
type OptionalStr = edgedbtypes.OptionalStr
OptionalStr is an optional string. Optional types must be used for out parameters when a shape field is not required.
type OptionalUUID ¶ added in v0.8.0
type OptionalUUID = edgedbtypes.OptionalUUID
OptionalUUID is an optional UUID. Optional types must be used for out parameters when a shape field is not required.
type RangeDateTime ¶ added in v0.12.0
type RangeDateTime = edgedbtypes.RangeDateTime
RangeDateTime is an interval of time.Time values.
type RangeFloat32 ¶ added in v0.12.0
type RangeFloat32 = edgedbtypes.RangeFloat32
RangeFloat32 is an interval of float32 values.
type RangeFloat64 ¶ added in v0.12.0
type RangeFloat64 = edgedbtypes.RangeFloat64
RangeFloat64 is an interval of float64 values.
type RangeInt32 ¶ added in v0.12.0
type RangeInt32 = edgedbtypes.RangeInt32
RangeInt32 is an interval of int32 values.
type RangeInt64 ¶ added in v0.12.0
type RangeInt64 = edgedbtypes.RangeInt64
RangeInt64 is an interval of int64 values.
type RangeLocalDate ¶ added in v0.12.0
type RangeLocalDate = edgedbtypes.RangeLocalDate
RangeLocalDate is an interval of LocalDate values.
type RangeLocalDateTime ¶ added in v0.12.0
type RangeLocalDateTime = edgedbtypes.RangeLocalDateTime
RangeLocalDateTime is an interval of LocalDateTime values.
type RelativeDuration ¶ added in v0.7.0
type RelativeDuration = edgedbtypes.RelativeDuration
RelativeDuration represents the elapsed time between two instants in a fuzzy human way.
type RetryBackoff ¶ added in v0.6.0
type RetryBackoff = edgedb.RetryBackoff
RetryBackoff returns the duration to wait after the nth attempt before making the next attempt when retrying a transaction.
type RetryCondition ¶ added in v0.6.0
type RetryCondition = edgedb.RetryCondition
RetryCondition represents scenarios that can caused a transaction run in Tx() methods to be retried.
type RetryOptions ¶ added in v0.6.0
type RetryOptions = edgedb.RetryOptions
RetryOptions configures how Tx() retries failed transactions. Use NewRetryOptions to get a default RetryOptions value instead of creating one yourself.
type RetryRule ¶ added in v0.6.0
RetryRule determines how transactions should be retried when run in Tx() methods. See Client.Tx() for details.
type TLSOptions ¶ added in v0.9.1
type TLSOptions = edgedb.TLSOptions
TLSOptions contains the parameters needed to configure TLS on EdgeDB server connections.
type TLSSecurityMode ¶ added in v0.9.1
type TLSSecurityMode = edgedb.TLSSecurityMode
TLSSecurityMode specifies how strict TLS validation is.
type Tx ¶
Tx is a transaction. Use Client.Tx() to get a transaction.
Example ¶
Transactions can be executed using the Tx() method. Note that queries are executed on the Tx object. Queries executed on the client in a transaction callback will not run in the transaction and will be applied immediately. In edgedb-go the callback may be re-run if any of the queries fail in a way that might succeed on subsequent attempts. Transaction behavior can be configured with TxOptions and the retrying behavior can be configured with RetryOptions.
package main import ( "context" "log" edgedb "github.com/edgedb/edgedb-go/internal/client" ) func main() { ctx := context.Background() client, err := edgedb.CreateClient(ctx, edgedb.Options{}) err = client.Tx(ctx, func(ctx context.Context, tx *edgedb.Tx) error { return tx.Execute(ctx, "INSERT User { name := 'Don' }") }) if err != nil { log.Println(err) } }
Output:
type UUID ¶
type UUID = edgedbtypes.UUID
UUID is a universally unique identifier https://www.edgedb.com/docs/stdlib/uuid
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
edgeql-go
edgeql-go is a tool to generate go functions from edgeql queries.
|
edgeql-go is a tool to generate go functions from edgeql queries. |
edgedb
module
|
|
marshal
Package marshal documents marshaling interfaces.
|
Package marshal documents marshaling interfaces. |
soc
Package soc has utilities for working with sockets.
|
Package soc has utilities for working with sockets. |