Documentation ¶
Overview ¶
Package arangolite provides a lightweight ArangoDatabase driver.
Index ¶
- func HasErrorNum(err error, errorNum ...int) bool
- func HasStatusCode(err error, statusCode ...int) bool
- func IsErrForbidden(err error) bool
- func IsErrInvalidRequest(err error) bool
- func IsErrNotFound(err error) bool
- func IsErrUnauthorized(err error) bool
- func IsErrUnique(err error) bool
- type Database
- type Document
- type Edge
- type LogVerbosity
- type Option
- type Response
- type Runnable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasErrorNum ¶
HasErrorNum returns true when one of the given error num matches the one returned by the database.
func HasStatusCode ¶
HasStatusCode returns true when one of the given error status code matches the one returned by the database.
func IsErrForbidden ¶
IsErrForbidden returns true when the database returns a 403.
func IsErrInvalidRequest ¶
IsErrInvalidRequest returns true when the database returns a 400.
func IsErrNotFound ¶
IsErrNotFound returns true when the database returns a 404 or when the error num is: 1202 - ERROR_ARANGO_DOCUMENT_NOT_FOUND 1203 - ERROR_ARANGO_COLLECTION_NOT_FOUND
func IsErrUnauthorized ¶
IsErrUnauthorized returns true when the database returns a 401.
func IsErrUnique ¶
IsErrUnique returns true when the error num is a 1210 - ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents an access to an ArangoDB database.
func NewDatabase ¶
NewDatabase returns a new Database object.
type Document ¶
type Document struct { // The document handle. Format: ':collection/:key' ID string `json:"_id,omitempty"` // The document's revision token. Changes at each update. Rev string `json:"_rev,omitempty"` // The document's unique key. Key string `json:"_key,omitempty"` }
Document represents a basic ArangoDB document Fields are pointers to allow null values in ArangoDB
type Edge ¶
type Edge struct { Document // Reference to another document. Format: ':collection/:key' From string `json:"_from,omitempty"` // Reference to another document. Format: ':collection/:key' To string `json:"_to,omitempty"` }
Edge represents a basic ArangoDB edge Fields are pointers to allow null values in ArangoDB
type LogVerbosity ¶
type LogVerbosity int
LogVerbosity is the logging verbosity.
const ( // LogSummary prints a simple summary of the exchanges with the database. LogSummary LogVerbosity = iota // LogDebug prints all the sent and received http requests. LogDebug )
type Option ¶
type Option func(db *Database)
Option sets an option for the database connection.
func OptBasicAuth ¶
OptBasicAuth sets the username and password used to access the database using basic authentication.
func OptDatabaseName ¶
OptDatabaseName sets the name of the targeted database.
func OptEndpoint ¶
OptEndpoint sets the endpoint used to access the database.
func OptHTTPClient ¶
OptHTTPClient sets the HTTP client used to interact with the database. It is also the current solution to set a custom TLS config.
func OptJWTAuth ¶
OptJWTAuth sets the username and password used to access the database using JWT authentication.
func OptLogging ¶
func OptLogging(logger *log.Logger, verbosity LogVerbosity) Option
OptLogging enables logging of the exchanges with the database.
type Response ¶
type Response interface { // The raw response from the database. Raw() json.RawMessage // The raw response result, if present. RawResult() json.RawMessage // The response HTTP status code. StatusCode() int // HasMore indicates if a next result page is available. HasMore() bool // The cursor ID if more result pages are available. Cursor() string // Unmarshal decodes the response into the given object. Unmarshal(v interface{}) error // UnmarshalResult decodes the value of the Result field into the given object, if present. UnmarshalResult(v interface{}) error }
Response defines the response returned by the execution of a Runnable.
type Runnable ¶ added in v1.2.0
type Runnable interface { // The body of the request. Generate() []byte // The path where to send the request. Path() string // The HTTP method to use. Method() string }
Runnable defines requests runnable by the Run and Send methods. A Runnable library is located in the 'requests' package.