driver

package module
v0.0.0-...-d121e6a Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

ArangoDB-Logo

ArangoDB GO Driver

This project contains the official Go driver for the ArangoDB database.

Build Status GoDoc

Documentation

Overview

Package driver implements a Go driver for the ArangoDB database.

To get started, create a connection to the database and wrap a client around it.

// Create an HTTP connection to the database
conn, err := http.NewConnection(http.ConnectionConfig{
	Endpoints: []string{"http://localhost:8529"},
})
if err != nil {
	// Handle error
}
// Create a client
c, err := driver.NewClient(driver.ClientConfig{
	Connection: conn,
})
if err != nil {
	// Handle error
}
Example (CreateDocument)
//
// DISCLAIMER
//
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Ewout Prangsma
//

//go:build !auth
// +build !auth

// This example demonstrates how to create a single document.
package main

import (
	"fmt"
	"log"

	driver "github.com/realox/go-driver"
	"github.com/realox/go-driver/http"
)

type Book struct {
	Title   string `arango:"title" json:"title"`
	NoPages int    `arango:"no_pages" json:"no_pages"`
}

func main() {
	conn, err := http.NewConnection(http.ConnectionConfig{
		Endpoints: []string{"http://localhost:8529"},
	})
	if err != nil {
		log.Fatalf("Failed to create HTTP connection: %v", err)
	}
	c, err := driver.NewClient(driver.ClientConfig{
		Connection: conn,
	})

	// Create database
	db, err := c.CreateDatabase(nil, "examples_books", nil)
	if err != nil {
		log.Fatalf("Failed to create database: %v", err)
	}

	// Create collection
	col, err := db.CreateCollection(nil, "books", nil)
	if err != nil {
		log.Fatalf("Failed to create collection: %v", err)
	}

	// Create document
	book := Book{
		Title:   "ArangoDB Cookbook",
		NoPages: 257,
	}
	meta, err := col.CreateDocument(nil, book)
	if err != nil {
		log.Fatalf("Failed to create document: %v", err)
	}
	fmt.Printf("Created document in collection '%s' in database '%s'\n", col.Name(), db.Name())

	// Read the document back
	var result Book
	if _, err := col.ReadDocument(nil, meta.Key, &result); err != nil {
		log.Fatalf("Failed to read document: %v", err)
	}
	fmt.Printf("Read book '%+v'\n", result)

}
Output:

Created document in collection 'books' in database 'examples_books'
Read book '{Title:ArangoDB Cookbook NoPages:257}'
Example (CreateDocuments)
//
// DISCLAIMER
//
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Ewout Prangsma
//

//go:build !auth
// +build !auth

// This example demonstrates how to create multiple documents at once.
package main

import (
	"flag"
	"fmt"
	"log"
	"strings"

	driver "github.com/realox/go-driver"
	"github.com/realox/go-driver/http"
)

type User struct {
	Name string `arango:"name" json:"name"`
	Age  int    `arango:"age" json:"age"`
}

func main() {
	flag.Parse()
	conn, err := http.NewConnection(http.ConnectionConfig{
		Endpoints: []string{"http://localhost:8529"},
	})
	if err != nil {
		log.Fatalf("Failed to create HTTP connection: %v", err)
	}
	c, err := driver.NewClient(driver.ClientConfig{
		Connection: conn,
	})

	// Create database
	db, err := c.CreateDatabase(nil, "examples_users", nil)
	if err != nil {
		log.Fatalf("Failed to create database: %v", err)
	}

	// Create collection
	col, err := db.CreateCollection(nil, "users", nil)
	if err != nil {
		log.Fatalf("Failed to create collection: %v", err)
	}

	// Create documents
	users := []User{
		User{
			Name: "John",
			Age:  65,
		},
		User{
			Name: "Tina",
			Age:  25,
		},
		User{
			Name: "George",
			Age:  31,
		},
	}
	metas, errs, err := col.CreateDocuments(nil, users)
	if err != nil {
		log.Fatalf("Failed to create documents: %v", err)
	} else if err := errs.FirstNonNil(); err != nil {
		log.Fatalf("Failed to create documents: first error: %v", err)
	}

	fmt.Printf("Created documents with keys '%s' in collection '%s' in database '%s'\n", strings.Join(metas.Keys(), ","), col.Name(), db.Name())
}
Output:

Example (CreateGraph)
//
// DISCLAIMER
//
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

//go:build !auth
// +build !auth

// This example demonstrates how to create a graph, how to add vertices and edges and how to delete it again.
package main

import (
	"fmt"
	"log"

	driver "github.com/realox/go-driver"
	"github.com/realox/go-driver/http"
)

type MyObject struct {
	Name string `json:"_key"`
	Age  int    `json:"age"`
}

type MyEdgeObject struct {
	From string `json:"_from"`
	To   string `json:"_to"`
}

func main() {
	fmt.Println("Hello World")

	// Create an HTTP connection to the database
	conn, err := http.NewConnection(http.ConnectionConfig{
		Endpoints: []string{"http://localhost:8529"},
	})
	if err != nil {
		log.Fatalf("Failed to create HTTP connection: %v", err)
	}
	// Create a client
	c, err := driver.NewClient(driver.ClientConfig{
		Connection: conn,
	})

	// Create database
	db, err := c.CreateDatabase(nil, "my_graph_db", nil)
	if err != nil {
		log.Fatalf("Failed to create database: %v", err)
	}

	// define the edgeCollection to store the edges
	var edgeDefinition driver.EdgeDefinition
	edgeDefinition.Collection = "myEdgeCollection"
	// define a set of collections where an edge is going out...
	edgeDefinition.From = []string{"myCollection1", "myCollection2"}

	// repeat this for the collections where an edge is going into
	edgeDefinition.To = []string{"myCollection1", "myCollection3"}

	// A graph can contain additional vertex collections, defined in the set of orphan collections
	var options driver.CreateGraphOptions
	options.OrphanVertexCollections = []string{"myCollection4", "myCollection5"}
	options.EdgeDefinitions = []driver.EdgeDefinition{edgeDefinition}

	// now it's possible to create a graph
	graph, err := db.CreateGraph(nil, "myGraph", &options)
	if err != nil {
		log.Fatalf("Failed to create graph: %v", err)
	}

	// add vertex
	vertexCollection1, err := graph.VertexCollection(nil, "myCollection1")
	if err != nil {
		log.Fatalf("Failed to get vertex collection: %v", err)
	}

	myObjects := []MyObject{
		MyObject{
			"Homer",
			38,
		},
		MyObject{
			"Marge",
			36,
		},
	}
	_, _, err = vertexCollection1.CreateDocuments(nil, myObjects)
	if err != nil {
		log.Fatalf("Failed to create vertex documents: %v", err)
	}

	// add edge
	edgeCollection, _, err := graph.EdgeCollection(nil, "myEdgeCollection")
	if err != nil {
		log.Fatalf("Failed to select edge collection: %v", err)
	}

	edge := MyEdgeObject{From: "myCollection1/Homer", To: "myCollection1/Marge"}
	_, err = edgeCollection.CreateDocument(nil, edge)
	if err != nil {
		log.Fatalf("Failed to create edge document: %v", err)
	}

	// delete graph
	graph.Remove(nil)
}
Output:

Index

Examples

Constants

View Source
const (
	CollectionStatusNewBorn   = CollectionStatus(1)
	CollectionStatusUnloaded  = CollectionStatus(2)
	CollectionStatusLoaded    = CollectionStatus(3)
	CollectionStatusUnloading = CollectionStatus(4)
	CollectionStatusDeleted   = CollectionStatus(5)
	CollectionStatusLoading   = CollectionStatus(6)
)
View Source
const (
	// ImportOnDuplicateError will not import the current document because of the unique key constraint violation.
	// This is the default setting.
	ImportOnDuplicateError = ImportOnDuplicate("error")
	// ImportOnDuplicateUpdate will update an existing document in the database with the data specified in the request.
	// Attributes of the existing document that are not present in the request will be preseved.
	ImportOnDuplicateUpdate = ImportOnDuplicate("update")
	// ImportOnDuplicateReplace will replace an existing document in the database with the data specified in the request.
	ImportOnDuplicateReplace = ImportOnDuplicate("replace")
	// ImportOnDuplicateIgnore will not update an existing document and simply ignore the error caused by a unique key constraint violation.
	ImportOnDuplicateIgnore = ImportOnDuplicate("ignore")
)
View Source
const (
	EngineTypeMMFiles = EngineType("mmfiles")
	EngineTypeRocksDB = EngineType("rocksdb")
)
View Source
const (
	// CollectionTypeDocument specifies a document collection
	CollectionTypeDocument = CollectionType(2)
	// CollectionTypeEdge specifies an edges collection
	CollectionTypeEdge = CollectionType(3)
)
View Source
const (
	KeyGeneratorTraditional   = KeyGeneratorType("traditional")
	KeyGeneratorAutoIncrement = KeyGeneratorType("autoincrement")
)
View Source
const (
	PrimaryIndex    = IndexType("primary")
	FullTextIndex   = IndexType("fulltext")
	HashIndex       = IndexType("hash")
	SkipListIndex   = IndexType("skiplist")
	PersistentIndex = IndexType("persistent")
	GeoIndex        = IndexType("geo")
	EdgeIndex       = IndexType("edge")
)

Symbolic constants for index types

View Source
const (
	// ReplicationFactorSatellite represents a satellite collection's replication factor
	ReplicationFactorSatellite int = -1
)
View Source
const (
	// ViewTypeArangoSearch specifies an ArangoSearch view type.
	ViewTypeArangoSearch = ViewType("arangosearch")
)

Variables

View Source
var (
	// WithStack is called on every return of an error to add stacktrace information to the error.
	// When setting this function, also set the Cause function.
	// The interface of this function is compatible with functions in github.com/pkg/errors.
	WithStack = func(err error) error { return err }
	// Cause is used to get the root cause of the given error.
	// The interface of this function is compatible with functions in github.com/pkg/errors.
	Cause = func(err error) error { return err }
)

Functions

func IsArangoError

func IsArangoError(err error) bool

IsArangoError returns true when the given error is an ArangoError.

func IsArangoErrorWithCode

func IsArangoErrorWithCode(err error, code int) bool

IsArangoErrorWithCode returns true when the given error is an ArangoError and its Code field is equal to the given code.

func IsArangoErrorWithErrorNum

func IsArangoErrorWithErrorNum(err error, errorNum ...int) bool

IsArangoErrorWithErrorNum returns true when the given error is an ArangoError and its ErrorNum field is equal to one of the given numbers.

func IsCanceled

func IsCanceled(err error) bool

IsCanceled returns true if the given error is the result on a cancelled context.

func IsConflict

func IsConflict(err error) bool

IsConflict returns true if the given error is an ArangoError with code 409, indicating a conflict.

func IsForbidden

func IsForbidden(err error) bool

IsForbidden returns true if the given error is an ArangoError with code 403, indicating a forbidden request.

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument returns true if the given error is an InvalidArgumentError.

func IsInvalidRequest

func IsInvalidRequest(err error) bool

IsInvalidRequest returns true if the given error is an ArangoError with code 400, indicating an invalid request.

func IsNoLeader

func IsNoLeader(err error) bool

IsNoLeader returns true if the given error is an ArangoError with code 503 error number 1496.

func IsNoLeaderOrOngoing

func IsNoLeaderOrOngoing(err error) bool

IsNoLeaderOrOngoing return true if the given error is an ArangoError with code 503 and error number 1496 or 1495

func IsNoMoreDocuments

func IsNoMoreDocuments(err error) bool

IsNoMoreDocuments returns true if the given error is an NoMoreDocumentsError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the given error is an ArangoError with code 404, indicating a object not found.

func IsPreconditionFailed

func IsPreconditionFailed(err error) bool

IsPreconditionFailed returns true if the given error is an ArangoError with code 412, indicating a failed precondition.

func IsResponse

func IsResponse(err error) bool

IsResponse returns true if the given error is (or is caused by) a ResponseError.

func IsTimeout

func IsTimeout(err error) bool

IsTimeout returns true if the given error is the result on a deadline that has been exceeded.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns true if the given error is an ArangoError with code 401, indicating an unauthorized request.

func WithAllowDirtyReads

func WithAllowDirtyReads(parent context.Context, wasDirtyRead *bool) context.Context

WithAllowDirtyReads is used in an active failover deployment to allow reads from the follower. You can pass a reference to a boolean that will set according to wether a potentially dirty read happened or not. nil is allowed. This is valid for document reads, aql queries, gharial vertex and edge reads.

func WithBatchID

func WithBatchID(parent context.Context, id string) context.Context

WithBatchID is used to configure a context that includes an ID of a Batch. This is used in replication functions.

func WithConfigured

func WithConfigured(parent context.Context, value ...bool) context.Context

WithConfigured is used to configure a context to return the configured value of a user grant instead of the effective grant.

func WithDBServerID

func WithDBServerID(parent context.Context, id string) context.Context

WithDBServerID is used to configure a context that includes an ID of a specific DBServer.

func WithDetails

func WithDetails(parent context.Context, value ...bool) context.Context

WithDetails is used to configure a context to make Client.Version return additional details. You can pass a single (optional) boolean. If that is set to false, you explicitly ask to not provide details.

func WithEndpoint

func WithEndpoint(parent context.Context, endpoint string) context.Context

WithEndpoint is used to configure a context that forces a request to be executed on a specific endpoint. If you specify an endpoint like this, failover is disabled. If you specify an unknown endpoint, an InvalidArgumentError is returned from requests.

func WithEnforceReplicationFactor

func WithEnforceReplicationFactor(parent context.Context, value bool) context.Context

WithEnforceReplicationFactor is used to configure a context to make adding collections fail if the replication factor is too high (default or true) or silently accept (false).

func WithFollowLeaderRedirect

func WithFollowLeaderRedirect(parent context.Context, value bool) context.Context

WithFollowLeaderRedirect is used to configure a context to return turn on/off following redirection responses from the server when the request is answered by a follower. Default behavior is "on".

func WithIgnoreRevisions

func WithIgnoreRevisions(parent context.Context, value ...bool) context.Context

WithIgnoreRevisions is used to configure a context to make modification functions ignore revisions in the update. Do not use in combination with WithRevision or WithRevisions.

func WithImportDetails

func WithImportDetails(parent context.Context, value *[]string) context.Context

WithImportDetails is used to configure a context that will make import document requests return details about documents that could not be imported.

func WithIsRestore

func WithIsRestore(parent context.Context, value bool) context.Context

WithIsRestore is used to configure a context to make insert functions use the "isRestore=<value>" setting. Note: This function is intended for internal (replication) use. It is NOT intended to be used by normal client. This CAN screw up your database.

func WithIsSystem

func WithIsSystem(parent context.Context, value bool) context.Context

WithIsSystem is used to configure a context to make insert functions use the "isSystem=<value>" setting.

func WithJobIDResponse

func WithJobIDResponse(parent context.Context, jobID *string) context.Context

WithJobIDResponse is used to configure a context that includes a reference to a JobID that is filled on a error-free response. This is used in cluster functions.

func WithKeepNull

func WithKeepNull(parent context.Context, value bool) context.Context

WithKeepNull is used to configure a context to make update functions keep null fields (value==true) or remove fields with null values (value==false).

func WithMergeObjects

func WithMergeObjects(parent context.Context, value bool) context.Context

WithMergeObjects is used to configure a context to make update functions merge objects present in both the existing document and the patch document (value==true) or overwrite objects in the existing document with objects found in the patch document (value==false)

func WithQueryBatchSize

func WithQueryBatchSize(parent context.Context, value int) context.Context

WithQueryBatchSize is used to configure a context that will set the BatchSize of a query request,

func WithQueryCache

func WithQueryCache(parent context.Context, value ...bool) context.Context

WithQueryCache is used to configure a context that will set the Cache of a query request, If value is not given it defaults to true.

func WithQueryCount

func WithQueryCount(parent context.Context, value ...bool) context.Context

WithQueryCount is used to configure a context that will set the Count of a query request, If value is not given it defaults to true.

func WithQueryFullCount

func WithQueryFullCount(parent context.Context, value ...bool) context.Context

WithQueryFullCount is used to configure whether the query returns the full count of results before the last LIMIT statement

func WithQueryMaxRuntime

func WithQueryMaxRuntime(parent context.Context, value ...float64) context.Context

func WithQueryMemoryLimit

func WithQueryMemoryLimit(parent context.Context, value int64) context.Context

WithQueryMemoryLimit is used to configure a context that will set the MemoryList of a query request,

func WithQuerySatelliteSyncWait

func WithQuerySatelliteSyncWait(parent context.Context, value time.Duration) context.Context

WithQuerySatelliteSyncWait sets the satelliteSyncWait query value on the query cursor request

func WithQueryStream

func WithQueryStream(parent context.Context, value ...bool) context.Context

WithQueryStream is used to configure whether this becomes a stream query. A stream query is not executed right away, but continually evaluated when the client is requesting more results. Should the cursor expire the query transaction is canceled. This means for writing queries clients have to read the query-cursor until the HasMore() method returns false.

func WithQueryTTL

func WithQueryTTL(parent context.Context, value time.Duration) context.Context

WithQueryTTL is used to configure a context that will set the TTL of a query request,

func WithRawResponse

func WithRawResponse(parent context.Context, value *[]byte) context.Context

WithRawResponse is used to configure a context that will make all functions store the raw response into a buffer.

func WithResponse

func WithResponse(parent context.Context, value *Response) context.Context

WithResponse is used to configure a context that will make all functions store the response into the given value.

func WithReturnNew

func WithReturnNew(parent context.Context, result interface{}) context.Context

WithReturnNew is used to configure a context to make create, update & replace document functions return the new document into the given result.

func WithReturnOld

func WithReturnOld(parent context.Context, result interface{}) context.Context

WithReturnOld is used to configure a context to make update & replace document functions return the old document into the given result.

func WithRevision

func WithRevision(parent context.Context, revision string) context.Context

WithRevision is used to configure a context to make document functions specify an explicit revision of the document using an `If-Match` condition.

func WithRevisions

func WithRevisions(parent context.Context, revisions []string) context.Context

WithRevisions is used to configure a context to make multi-document functions specify explicit revisions of the documents.

func WithSilent

func WithSilent(parent context.Context, value ...bool) context.Context

WithSilent is used to configure a context to make functions return an empty result (silent==true), instead of a metadata result (silent==false, default). You can pass a single (optional) boolean. If that is set to false, you explicitly ask to return metadata result.

func WithWaitForSync

func WithWaitForSync(parent context.Context, value ...bool) context.Context

WithWaitForSync is used to configure a context to make modification functions wait until the data has been synced to disk (or not). You can pass a single (optional) boolean. If that is set to false, you explicitly do not wait for data to be synced to disk.

Types

type AccessTarget

type AccessTarget interface {
	// Name returns the name of the database/collection.
	Name() string
}

AccessTarget is implemented by Database & Collection and it used to get/set/remove collection permissions.

type ArangoError

type ArangoError struct {
	HasError     bool   `arango:"error" json:"error"`
	Code         int    `arango:"code" json:"code"`
	ErrorNum     int    `arango:"errorNum" json:"errorNum"`
	ErrorMessage string `arango:"errorMessage" json:"errorMessage"`
}

ArangoError is a Go error with arangodb specific error information.

func (ArangoError) Error

func (ae ArangoError) Error() string

Error returns the error message of an ArangoError.

func (ArangoError) Temporary

func (ae ArangoError) Temporary() bool

Temporary returns true when the given error is a temporary error.

func (ArangoError) Timeout

func (ae ArangoError) Timeout() bool

Timeout returns true when the given error is a timeout error.

type ArangoSearchConsolidationPolicy

type ArangoSearchConsolidationPolicy struct {
	// Type returns the type of the ConsolidationPolicy. This interface can then be casted to the corresponding ArangoSearchConsolidationPolicy* struct.
	Type ArangoSearchConsolidationPolicyType `json:"type,omitempty"`

	ArangoSearchConsolidationPolicyBytesAccum
	ArangoSearchConsolidationPolicyTier
}

ArangoSearchConsolidationPolicy holds threshold values specifying when to consolidate view data. Semantics of the values depend on where they are used.

type ArangoSearchConsolidationPolicyBytesAccum

type ArangoSearchConsolidationPolicyBytesAccum struct {
	// Threshold, see ArangoSearchConsolidationTypeBytesAccum
	Threshold *float64 `json:"threshold,omitempty"`
}

ArangoSearchConsolidationPolicyBytesAccum contains fields used for ArangoSearchConsolidationPolicyTypeBytesAccum

type ArangoSearchConsolidationPolicyTier

type ArangoSearchConsolidationPolicyTier struct {
	// MinSegments specifies the minimum number of segments that will be evaluated as candidates for consolidation.
	MinSegments *int64 `json:"minSegments,omitempty"`
	// MaxSegments specifies the maximum number of segments that will be evaluated as candidates for consolidation.
	MaxSegments *int64 `json:"maxSegments,omitempty"`
	// SegmentsBytesMax specifies the maxinum allowed size of all consolidated segments in bytes.
	SegmentsBytesMax *int64 `json:"segmentsBytesMax,omitempty"`
	// SegmentsBytesFloor defines the value (in bytes) to treat all smaller segments as equal for consolidation selection.
	SegmentsBytesFloor *int64 `json:"segmentsBytesFloor,omitempty"`
	// Lookahead specifies the number of additionally searched tiers except initially chosen candidated based on min_segments,
	// max_segments, segments_bytes_max, segments_bytes_floor with respect to defined values.
	// Default value falls to integer_traits<size_t>::const_max (in C++ source code).
	Lookahead *int64 `json:"lookahead,omitempty"`
}

ArangoSearchConsolidationPolicyTier contains fields used for ArangoSearchConsolidationPolicyTypeTier

type ArangoSearchConsolidationPolicyType

type ArangoSearchConsolidationPolicyType string

ArangoSearchConsolidationPolicyType strings for consolidation types

const (
	// ArangoSearchConsolidationPolicyTypeTier consolidate based on segment byte size and live document count as dictated by the customization attributes.
	ArangoSearchConsolidationPolicyTypeTier ArangoSearchConsolidationPolicyType = "tier"
	// ArangoSearchConsolidationPolicyTypeBytesAccum consolidate if and only if ({threshold} range [0.0, 1.0])
	// {threshold} > (segment_bytes + sum_of_merge_candidate_segment_bytes) / all_segment_bytes,
	// i.e. the sum of all candidate segment's byte size is less than the total segment byte size multiplied by the {threshold}.
	ArangoSearchConsolidationPolicyTypeBytesAccum ArangoSearchConsolidationPolicyType = "bytes_accum"
)

type ArangoSearchElementProperties

type ArangoSearchElementProperties struct {
	// The list of analyzers to be used for indexing of string values. Defaults to ["identify"].
	Analyzers []string `json:"analyzers,omitempty"`
	// If set to true, all fields of this element will be indexed. Defaults to false.
	IncludeAllFields *bool `json:"includeAllFields,omitempty"`
	// If set to true, values in a listed are treated as separate values. Defaults to false.
	TrackListPositions *bool `json:"trackListPositions,omitempty"`
	// This values specifies how the view should track values.
	StoreValues ArangoSearchStoreValues `json:"storeValues,omitempty"`
	// Fields contains the properties for individual fields of the element.
	// The key of the map are field names.
	Fields ArangoSearchFields `json:"fields,omitempty"`
}

ArangoSearchElementProperties contains properties that specify how an element is indexed in an ArangoSearch view. Note that this structure is recursive. Settings not specified (nil) at a given level will inherit their setting from a lower level.

type ArangoSearchFields

type ArangoSearchFields map[string]ArangoSearchElementProperties

ArangoSearchFields is a strongly typed map containing properties per field. The keys in the map are field names.

type ArangoSearchLinks map[string]ArangoSearchElementProperties

ArangoSearchLinks is a strongly typed map containing links between a collection and a view. The keys in the map are collection names.

type ArangoSearchStoreValues

type ArangoSearchStoreValues string

ArangoSearchStoreValues is the type of the StoreValues option of an ArangoSearch element.

const (
	// ArangoSearchStoreValuesNone specifies that a view should not store values.
	ArangoSearchStoreValuesNone ArangoSearchStoreValues = "none"
	// ArangoSearchStoreValuesID specifies that a view should only store
	// information about value presence, to allow use of the EXISTS() function.
	ArangoSearchStoreValuesID ArangoSearchStoreValues = "id"
)

type ArangoSearchView

type ArangoSearchView interface {
	// Include generic View functions
	View

	// Properties fetches extended information about the view.
	Properties(ctx context.Context) (ArangoSearchViewProperties, error)

	// SetProperties changes properties of the view.
	SetProperties(ctx context.Context, options ArangoSearchViewProperties) error
}

ArangoSearchView provides access to the information of a view. Views are only available in ArangoDB 3.4 and higher.

type ArangoSearchViewProperties

type ArangoSearchViewProperties struct {
	// CleanupIntervalStep specifies the minimum number of commits to wait between
	// removing unused files in the data directory.
	// Defaults to 10.
	// Use 0 to disable waiting.
	// For the case where the consolidation policies merge segments often
	// (i.e. a lot of commit+consolidate), a lower value will cause a lot of
	// disk space to be wasted.
	// For the case where the consolidation policies rarely merge segments
	// (i.e. few inserts/deletes), a higher value will impact performance
	// without any added benefits.
	CleanupIntervalStep *int64 `json:"cleanupIntervalStep,omitempty"`
	// ConsolidationInterval specifies the minimum number of milliseconds that must be waited
	// between committing index data changes and making them visible to queries.
	// Defaults to 60000.
	// Use 0 to disable.
	// For the case where there are a lot of inserts/updates, a lower value,
	// until commit, will cause the index not to account for them and memory usage
	// would continue to grow.
	// For the case where there are a few inserts/updates, a higher value will
	// impact performance and waste disk space for each commit call without
	// any added benefits.
	ConsolidationInterval *int64 `json:"consolidationIntervalMsec,omitempty"`
	// ConsolidationPolicy specifies thresholds for consolidation.
	ConsolidationPolicy *ArangoSearchConsolidationPolicy `json:"consolidationPolicy,omitempty"`

	// WriteBufferIdel specifies the maximum number of writers (segments) cached in the pool.
	// 0 value turns off caching, default value is 64.
	WriteBufferIdel *int64 `json:"writebufferIdle,omitempty"`

	// WriteBufferActive specifies the maximum number of concurrent active writers (segments) performs (a transaction).
	// Other writers (segments) are wait till current active writers (segments) finish.
	// 0 value turns off this limit and used by default.
	WriteBufferActive *int64 `json:"writebufferActive,omitempty"`

	// WriteBufferSizeMax specifies maximum memory byte size per writer (segment) before a writer (segment) flush is triggered.
	// 0 value turns off this limit fon any writer (buffer) and will be flushed only after a period defined for special thread during ArangoDB server startup.
	// 0 value should be used with carefully due to high potential memory consumption.
	WriteBufferSizeMax *int64 `json:"writebufferSizeMax,omitempty"`

	// Links contains the properties for how individual collections
	// are indexed in thie view.
	// The key of the map are collection names.
	Links ArangoSearchLinks `json:"links,omitempty"`
}

ArangoSearchViewProperties contains properties an an ArangoSearch view.

type Authentication

type Authentication interface {
	// Returns the type of authentication
	Type() AuthenticationType
	// Get returns a configuration property of the authentication.
	// Supported properties depend on type of authentication.
	Get(property string) string
}

Authentication implements a kind of authentication.

func BasicAuthentication

func BasicAuthentication(userName, password string) Authentication

BasicAuthentication creates an authentication implementation based on the given username & password.

func JWTAuthentication

func JWTAuthentication(userName, password string) Authentication

JWTAuthentication creates a JWT token authentication implementation based on the given username & password.

func RawAuthentication

func RawAuthentication(value string) Authentication

RawAuthentication creates a raw authentication implementation based on the given value for the Authorization header.

type AuthenticationType

type AuthenticationType int
const (
	// AuthenticationTypeBasic uses username+password basic authentication
	AuthenticationTypeBasic AuthenticationType = iota
	// AuthenticationTypeJWT uses username+password JWT token based authentication
	AuthenticationTypeJWT
	// AuthenticationTypeRaw uses a raw value for the Authorization header
	AuthenticationTypeRaw
)

type Batch

type Batch interface {
	// id of this batch
	BatchID() string
	// LastTick reported by the server for this batch
	LastTick() Tick
	// Extend the lifetime of an existing batch on the server
	Extend(ctx context.Context, ttl time.Duration) error
	// DeleteBatch deletes an existing batch on the server
	Delete(ctx context.Context) error
}

Batch represents state on the server used during certain replication operations to keep state required by the client (such as Write-Ahead Log, inventory and data-files)

type Client

type Client interface {
	// SynchronizeEndpoints fetches all endpoints from an ArangoDB cluster and updates the
	// connection to use those endpoints.
	// When this client is connected to a single server, nothing happens.
	// When this client is connected to a cluster of servers, the connection will be updated to reflect
	// the layout of the cluster.
	// This function requires ArangoDB 3.1.15 or up.
	SynchronizeEndpoints(ctx context.Context) error

	// SynchronizeEndpoints2 fetches all endpoints from an ArangoDB cluster and updates the
	// connection to use those endpoints.
	// When this client is connected to a single server, nothing happens.
	// When this client is connected to a cluster of servers, the connection will be updated to reflect
	// the layout of the cluster.
	// Compared to SynchronizeEndpoints, this function expects a database name as additional parameter.
	// This database name is used to call `_db/<dbname>/_api/cluster/endpoints`. SynchronizeEndpoints uses
	// the default database, i.e. `_system`. In the case the user does not have access to `_system`,
	// SynchronizeEndpoints does not work with earlier versions of arangodb.
	SynchronizeEndpoints2(ctx context.Context, dbname string) error

	// Connection returns the connection used by this client
	Connection() Connection

	// Database functions
	ClientDatabases

	// User functions
	ClientUsers

	// Cluster functions
	ClientCluster

	// Individual server information functions
	ClientServerInfo

	// Server/cluster administration functions
	ClientServerAdmin

	// Replication functions
	ClientReplication
}

Client provides access to a single arangodb database server, or an entire cluster of arangodb servers.

func NewClient

func NewClient(config ClientConfig) (Client, error)

NewClient creates a new Client based on the given config setting.

Example
package main

import (
	"fmt"
	"log"

	driver "github.com/realox/go-driver"
	"github.com/realox/go-driver/http"
)

func main() {
	// Create an HTTP connection to the database
	conn, err := http.NewConnection(http.ConnectionConfig{
		Endpoints: []string{"http://localhost:8529"},
	})
	if err != nil {
		log.Fatalf("Failed to create HTTP connection: %v", err)
	}
	// Create a client
	c, err := driver.NewClient(driver.ClientConfig{
		Connection: conn,
	})
	// Ask the version of the server
	versionInfo, err := c.Version(nil)
	if err != nil {
		log.Fatalf("Failed to get version info: %v", err)
	}
	fmt.Printf("Database has version '%s' and license '%s'\n", versionInfo.Version, versionInfo.License)
}
Output:

type ClientCluster

type ClientCluster interface {
	// Cluster provides access to cluster wide specific operations.
	// To use this interface, an ArangoDB cluster is required.
	// If this method is a called without a cluster, a PreconditionFailed error is returned.
	Cluster(ctx context.Context) (Cluster, error)
}

ClientCluster provides methods needed to access cluster functionality from a client.

type ClientConfig

type ClientConfig struct {
	// Connection is the actual server/cluster connection.
	// See http.NewConnection.
	Connection Connection
	// Authentication implements authentication on the server.
	Authentication Authentication
	// SynchronizeEndpointsInterval is the interval between automatisch synchronization of endpoints.
	// If this value is 0, no automatic synchronization is performed.
	// If this value is > 0, automatic synchronization is started on a go routine.
	// This feature requires ArangoDB 3.1.15 or up.
	SynchronizeEndpointsInterval time.Duration
}

ClientConfig contains all settings needed to create a client.

type ClientDatabases

type ClientDatabases interface {
	// Database opens a connection to an existing database.
	// If no database with given name exists, an NotFoundError is returned.
	Database(ctx context.Context, name string) (Database, error)

	// DatabaseExists returns true if a database with given name exists.
	DatabaseExists(ctx context.Context, name string) (bool, error)

	// Databases returns a list of all databases found by the client.
	Databases(ctx context.Context) ([]Database, error)

	// AccessibleDatabases returns a list of all databases that can be accessed by the authenticated user.
	AccessibleDatabases(ctx context.Context) ([]Database, error)

	// CreateDatabase creates a new database with given name and opens a connection to it.
	// If the a database with given name already exists, a DuplicateError is returned.
	CreateDatabase(ctx context.Context, name string, options *CreateDatabaseOptions) (Database, error)
}

ClientDatabases provides access to the databases in a single arangodb database server, or an entire cluster of arangodb servers.

type ClientReplication

type ClientReplication interface {
	// Replication provides access to replication specific operations.
	Replication() Replication
}

ClientReplication provides methods needed to access replication functionality from a client.

type ClientServerAdmin

type ClientServerAdmin interface {
	// ServerMode returns the current mode in which the server/cluster is operating.
	// This call needs ArangoDB 3.3 and up.
	ServerMode(ctx context.Context) (ServerMode, error)
	// SetServerMode changes the current mode in which the server/cluster is operating.
	// This call needs a client that uses JWT authentication.
	// This call needs ArangoDB 3.3 and up.
	SetServerMode(ctx context.Context, mode ServerMode) error

	// Shutdown a specific server, optionally removing it from its cluster.
	Shutdown(ctx context.Context, removeFromCluster bool) error
}

ClientServerAdmin provides access to server administrations functions of an arangodb database server or an entire cluster of arangodb servers.

type ClientServerInfo

type ClientServerInfo interface {
	// Version returns version information from the connected database server.
	// Use WithDetails to configure a context that will include additional details in the return VersionInfo.
	Version(ctx context.Context) (VersionInfo, error)

	// ServerRole returns the role of the server that answers the request.
	ServerRole(ctx context.Context) (ServerRole, error)

	// Gets the ID of this server in the cluster.
	// An error is returned when calling this to a server that is not part of a cluster.
	ServerID(ctx context.Context) (string, error)
}

ClientServerInfo provides access to information about a single ArangoDB server. When your client uses multiple endpoints, it is undefined which server will respond to requests of this interface.

type ClientUsers

type ClientUsers interface {
	// User opens a connection to an existing user.
	// If no user with given name exists, an NotFoundError is returned.
	User(ctx context.Context, name string) (User, error)

	// UserExists returns true if a user with given name exists.
	UserExists(ctx context.Context, name string) (bool, error)

	// Users returns a list of all users found by the client.
	Users(ctx context.Context) ([]User, error)

	// CreateUser creates a new user with given name and opens a connection to it.
	// If a user with given name already exists, a Conflict error is returned.
	CreateUser(ctx context.Context, name string, options *UserOptions) (User, error)
}

ClientUsers provides access to the users in a single arangodb database server, or an entire cluster of arangodb servers.

type Cluster

type Cluster interface {
	// Get the cluster configuration & health
	Health(ctx context.Context) (ClusterHealth, error)

	// Get the inventory of the cluster containing all collections (with entire details) of a database.
	DatabaseInventory(ctx context.Context, db Database) (DatabaseInventory, error)

	// MoveShard moves a single shard of the given collection from server `fromServer` to
	// server `toServer`.
	MoveShard(ctx context.Context, col Collection, shard ShardID, fromServer, toServer ServerID) error

	// CleanOutServer triggers activities to clean out a DBServer.
	CleanOutServer(ctx context.Context, serverID string) error

	// IsCleanedOut checks if the dbserver with given ID has been cleaned out.
	IsCleanedOut(ctx context.Context, serverID string) (bool, error)

	// RemoveServer is a low-level option to remove a server from a cluster.
	// This function is suitable for servers of type coordinator or dbserver.
	// The use of `ClientServerAdmin.Shutdown` is highly recommended above this function.
	RemoveServer(ctx context.Context, serverID ServerID) error
}

Cluster provides access to cluster wide specific operations. To use this interface, an ArangoDB cluster is required.

type ClusterHealth

type ClusterHealth struct {
	// Unique identifier of the entire cluster.
	// This ID is created when the cluster was first created.
	ID string `json:"ClusterId"`
	// Health per server
	Health map[ServerID]ServerHealth `json:"Health"`
}

ClusterHealth contains health information for all servers in a cluster.

type Collection

type Collection interface {
	// Name returns the name of the collection.
	Name() string

	// Database returns the database containing the collection.
	Database() Database

	// Status fetches the current status of the collection.
	Status(ctx context.Context) (CollectionStatus, error)

	// Count fetches the number of document in the collection.
	Count(ctx context.Context) (int64, error)

	// Statistics returns the number of documents and additional statistical information about the collection.
	Statistics(ctx context.Context) (CollectionStatistics, error)

	// Revision fetches the revision ID of the collection.
	// The revision ID is a server-generated string that clients can use to check whether data
	// in a collection has changed since the last revision check.
	Revision(ctx context.Context) (string, error)

	// Properties fetches extended information about the collection.
	Properties(ctx context.Context) (CollectionProperties, error)

	// SetProperties changes properties of the collection.
	SetProperties(ctx context.Context, options SetCollectionPropertiesOptions) error

	// Load the collection into memory.
	Load(ctx context.Context) error

	// UnLoad the collection from memory.
	Unload(ctx context.Context) error

	// Remove removes the entire collection.
	// If the collection does not exist, a NotFoundError is returned.
	Remove(ctx context.Context) error

	// Truncate removes all documents from the collection, but leaves the indexes intact.
	Truncate(ctx context.Context) error

	// All index functions
	CollectionIndexes

	// All document functions
	CollectionDocuments
}

Collection provides access to the information of a single collection, all its documents and all its indexes.

type CollectionDocuments

type CollectionDocuments interface {
	// DocumentExists checks if a document with given key exists in the collection.
	DocumentExists(ctx context.Context, key string) (bool, error)

	// ReadDocument reads a single document with given key from the collection.
	// The document data is stored into result, the document meta data is returned.
	// If no document exists with given key, a NotFoundError is returned.
	ReadDocument(ctx context.Context, key string, result interface{}) (DocumentMeta, error)

	// ReadDocuments reads multiple documents with given keys from the collection.
	// The documents data is stored into elements of the given results slice,
	// the documents meta data is returned.
	// If no document exists with a given key, a NotFoundError is returned at its errors index.
	ReadDocuments(ctx context.Context, keys []string, results interface{}) (DocumentMetaSlice, ErrorSlice, error)

	// CreateDocument creates a single document in the collection.
	// The document data is loaded from the given document, the document meta data is returned.
	// If the document data already contains a `_key` field, this will be used as key of the new document,
	// otherwise a unique key is created.
	// A ConflictError is returned when a `_key` field contains a duplicate key, other any other field violates an index constraint.
	// To return the NEW document, prepare a context with `WithReturnNew`.
	// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
	CreateDocument(ctx context.Context, document interface{}) (DocumentMeta, error)

	// CreateDocuments creates multiple documents in the collection.
	// The document data is loaded from the given documents slice, the documents meta data is returned.
	// If a documents element already contains a `_key` field, this will be used as key of the new document,
	// otherwise a unique key is created.
	// If a documents element contains a `_key` field with a duplicate key, other any other field violates an index constraint,
	// a ConflictError is returned in its inded in the errors slice.
	// To return the NEW documents, prepare a context with `WithReturnNew`. The data argument passed to `WithReturnNew` must be
	// a slice with the same number of entries as the `documents` slice.
	// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
	// If the create request itself fails or one of the arguments is invalid, an error is returned.
	CreateDocuments(ctx context.Context, documents interface{}) (DocumentMetaSlice, ErrorSlice, error)

	// UpdateDocument updates a single document with given key in the collection.
	// The document meta data is returned.
	// To return the NEW document, prepare a context with `WithReturnNew`.
	// To return the OLD document, prepare a context with `WithReturnOld`.
	// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
	// If no document exists with given key, a NotFoundError is returned.
	UpdateDocument(ctx context.Context, key string, update interface{}) (DocumentMeta, error)

	// UpdateDocuments updates multiple document with given keys in the collection.
	// The updates are loaded from the given updates slice, the documents meta data are returned.
	// To return the NEW documents, prepare a context with `WithReturnNew` with a slice of documents.
	// To return the OLD documents, prepare a context with `WithReturnOld` with a slice of documents.
	// To wait until documents has been synced to disk, prepare a context with `WithWaitForSync`.
	// If no document exists with a given key, a NotFoundError is returned at its errors index.
	// If keys is nil, each element in the updates slice must contain a `_key` field.
	UpdateDocuments(ctx context.Context, keys []string, updates interface{}) (DocumentMetaSlice, ErrorSlice, error)

	// ReplaceDocument replaces a single document with given key in the collection with the document given in the document argument.
	// The document meta data is returned.
	// To return the NEW document, prepare a context with `WithReturnNew`.
	// To return the OLD document, prepare a context with `WithReturnOld`.
	// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
	// If no document exists with given key, a NotFoundError is returned.
	ReplaceDocument(ctx context.Context, key string, document interface{}) (DocumentMeta, error)

	// ReplaceDocuments replaces multiple documents with given keys in the collection with the documents given in the documents argument.
	// The replacements are loaded from the given documents slice, the documents meta data are returned.
	// To return the NEW documents, prepare a context with `WithReturnNew` with a slice of documents.
	// To return the OLD documents, prepare a context with `WithReturnOld` with a slice of documents.
	// To wait until documents has been synced to disk, prepare a context with `WithWaitForSync`.
	// If no document exists with a given key, a NotFoundError is returned at its errors index.
	// If keys is nil, each element in the documents slice must contain a `_key` field.
	ReplaceDocuments(ctx context.Context, keys []string, documents interface{}) (DocumentMetaSlice, ErrorSlice, error)

	// RemoveDocument removes a single document with given key from the collection.
	// The document meta data is returned.
	// To return the OLD document, prepare a context with `WithReturnOld`.
	// To wait until removal has been synced to disk, prepare a context with `WithWaitForSync`.
	// If no document exists with given key, a NotFoundError is returned.
	RemoveDocument(ctx context.Context, key string) (DocumentMeta, error)

	// RemoveDocuments removes multiple documents with given keys from the collection.
	// The document meta data are returned.
	// To return the OLD documents, prepare a context with `WithReturnOld` with a slice of documents.
	// To wait until removal has been synced to disk, prepare a context with `WithWaitForSync`.
	// If no document exists with a given key, a NotFoundError is returned at its errors index.
	RemoveDocuments(ctx context.Context, keys []string) (DocumentMetaSlice, ErrorSlice, error)

	// ImportDocuments imports one or more documents into the collection.
	// The document data is loaded from the given documents argument, statistics are returned.
	// The documents argument can be one of the following:
	// - An array of structs: All structs will be imported as individual documents.
	// - An array of maps: All maps will be imported as individual documents.
	// To wait until all documents have been synced to disk, prepare a context with `WithWaitForSync`.
	// To return details about documents that could not be imported, prepare a context with `WithImportDetails`.
	ImportDocuments(ctx context.Context, documents interface{}, options *ImportDocumentOptions) (ImportDocumentStatistics, error)
}

CollectionDocuments provides access to the documents in a single collection.

type CollectionIndexes

type CollectionIndexes interface {
	// Index opens a connection to an existing index within the collection.
	// If no index with given name exists, an NotFoundError is returned.
	Index(ctx context.Context, name string) (Index, error)

	// IndexExists returns true if an index with given name exists within the collection.
	IndexExists(ctx context.Context, name string) (bool, error)

	// Indexes returns a list of all indexes in the collection.
	Indexes(ctx context.Context) ([]Index, error)

	// EnsureFullTextIndex creates a fulltext index in the collection, if it does not already exist.
	// Fields is a slice of attribute names. Currently, the slice is limited to exactly one attribute.
	// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
	EnsureFullTextIndex(ctx context.Context, fields []string, options *EnsureFullTextIndexOptions) (Index, bool, error)

	// EnsureGeoIndex creates a hash index in the collection, if it does not already exist.
	// Fields is a slice with one or two attribute paths. If it is a slice with one attribute path location,
	// then a geo-spatial index on all documents is created using location as path to the coordinates.
	// The value of the attribute must be a slice with at least two double values. The slice must contain the latitude (first value)
	// and the longitude (second value). All documents, which do not have the attribute path or with value that are not suitable, are ignored.
	// If it is a slice with two attribute paths latitude and longitude, then a geo-spatial index on all documents is created
	// using latitude and longitude as paths the latitude and the longitude. The value of the attribute latitude and of the
	// attribute longitude must a double. All documents, which do not have the attribute paths or which values are not suitable, are ignored.
	// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
	EnsureGeoIndex(ctx context.Context, fields []string, options *EnsureGeoIndexOptions) (Index, bool, error)

	// EnsureHashIndex creates a hash index in the collection, if it does not already exist.
	// Fields is a slice of attribute paths.
	// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
	EnsureHashIndex(ctx context.Context, fields []string, options *EnsureHashIndexOptions) (Index, bool, error)

	// EnsurePersistentIndex creates a persistent index in the collection, if it does not already exist.
	// Fields is a slice of attribute paths.
	// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
	EnsurePersistentIndex(ctx context.Context, fields []string, options *EnsurePersistentIndexOptions) (Index, bool, error)

	// EnsureSkipListIndex creates a skiplist index in the collection, if it does not already exist.
	// Fields is a slice of attribute paths.
	// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
	EnsureSkipListIndex(ctx context.Context, fields []string, options *EnsureSkipListIndexOptions) (Index, bool, error)
}

CollectionIndexes provides access to the indexes in a single collection.

type CollectionInfo

type CollectionInfo struct {
	// The identifier of the collection.
	ID string `arango:"id,omitempty" json:"id,omitempty"`
	// The name of the collection.
	Name string `arango:"name,omitempty" json:"name,omitempty"`
	// The status of the collection
	Status CollectionStatus `arango:"status,omitempty" json:"status,omitempty"`
	// The type of the collection
	Type CollectionType `arango:"type,omitempty" json:"type,omitempty"`
	// If true then the collection is a system collection.
	IsSystem bool `arango:"isSystem,omitempty" json:"isSystem,omitempty"`
}

CollectionInfo contains information about a collection

type CollectionKeyOptions

type CollectionKeyOptions struct {
	// If set to true, then it is allowed to supply own key values in the _key attribute of a document.
	// If set to false, then the key generator will solely be responsible for generating keys and supplying own
	// key values in the _key attribute of documents is considered an error.
	AllowUserKeys bool `arango:"allowUserKeys,omitempty" json:"allowUserKeys,omitempty"`
	// Specifies the type of the key generator. The currently available generators are traditional and autoincrement.
	Type KeyGeneratorType `arango:"type,omitempty" json:"type,omitempty"`
	// increment value for autoincrement key generator. Not used for other key generator types.
	Increment int `arango:"increment,omitempty" json:"increment,omitempty"`
	// Initial offset value for autoincrement key generator. Not used for other key generator types.
	Offset int `arango:"offset,omitempty" json:"offset,omitempty"`
}

CollectionKeyOptions specifies ways for creating keys of a collection.

type CollectionProperties

type CollectionProperties struct {
	CollectionInfo

	// WaitForSync; If true then creating, changing or removing documents will wait until the data has been synchronized to disk.
	WaitForSync bool `arango:"waitForSync,omitempty" json:"waitForSync,omitempty"`
	// DoCompact specifies whether or not the collection will be compacted.
	DoCompact bool `arango:"doCompact,omitempty" json:"doCompact,omitempty"`
	// JournalSize is the maximal size setting for journals / datafiles in bytes.
	JournalSize int64 `arango:"journalSize,omitempty" json:"journalSize,omitempty"`
	KeyOptions  struct {
		// Type specifies the type of the key generator. The currently available generators are traditional and autoincrement.
		Type KeyGeneratorType `arango:"type,omitempty" json:"type,omitempty"`
		// AllowUserKeys; if set to true, then it is allowed to supply own key values in the _key attribute of a document.
		// If set to false, then the key generator is solely responsible for generating keys and supplying own key values in
		// the _key attribute of documents is considered an error.
		AllowUserKeys bool `arango:"allowUserKeys,omitempty" json:"allowUserKeys,omitempty"`
	} `arango:"keyOptions,omitempty" json:"keyOptions,omitempty"`
	// NumberOfShards is the number of shards of the collection.
	// Only available in cluster setup.
	NumberOfShards int `arango:"numberOfShards,omitempty" json:"numberOfShards,omitempty"`
	// ShardKeys contains the names of document attributes that are used to determine the target shard for documents.
	// Only available in cluster setup.
	ShardKeys []string `arango:"shardKeys,omitempty" json:"shardKeys,omitempty"`
	// ReplicationFactor contains how many copies of each shard are kept on different DBServers.
	// Only available in cluster setup.
	ReplicationFactor int `arango:"replicationFactor,omitempty" json:"replicationFactor,omitempty"`
	// SmartJoinAttribute
	// See documentation for smart joins.
	// This requires ArangoDB Enterprise Edition.
	SmartJoinAttribute string `arango:"smartJoinAttribute,omitempty" json:"smartJoinAttribute,omitempty"`
	// This attribute specifies the name of the sharding strategy to use for the collection.
	// Can not be changed after creation.
	ShardingStrategy ShardingStrategy `arango:"shardingStrategy,omitempty" json:"shardingStrategy,omitempty"`
}

CollectionProperties contains extended information about a collection.

func (*CollectionProperties) IsSatellite

func (p *CollectionProperties) IsSatellite() bool

IsSatellite returns true if the collection is a satellite collection

func (*CollectionProperties) MarshalJSON

func (p *CollectionProperties) MarshalJSON() ([]byte, error)

MarshalJSON converts CollectionProperties into json

func (*CollectionProperties) UnmarshalJSON

func (p *CollectionProperties) UnmarshalJSON(d []byte) error

UnmarshalJSON loads CollectionProperties from json

type CollectionStatistics

type CollectionStatistics struct {
	//The number of documents currently present in the collection.
	Count int64 `arango:"count,omitempty" json:"count,omitempty"`
	// The maximal size of a journal or datafile in bytes.
	JournalSize int64 `arango:"journalSize,omitempty" json:"journalSize,omitempty"`
	Figures     struct {
		DataFiles struct {
			// The number of datafiles.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The total filesize of datafiles (in bytes).
			FileSize int64 `arango:"fileSize,omitempty" json:"fileSize,omitempty"`
		} `arango:"datafiles" json:"datafiles"`
		// The number of markers in the write-ahead log for this collection that have not been transferred to journals or datafiles.
		UncollectedLogfileEntries int64 `arango:"uncollectedLogfileEntries,omitempty" json:"uncollectedLogfileEntries,omitempty"`
		// The number of references to documents in datafiles that JavaScript code currently holds. This information can be used for debugging compaction and unload issues.
		DocumentReferences int64 `arango:"documentReferences,omitempty" json:"documentReferences,omitempty"`
		CompactionStatus   struct {
			// The action that was performed when the compaction was last run for the collection. This information can be used for debugging compaction issues.
			Message string `arango:"message,omitempty" json:"message,omitempty"`
			// The point in time the compaction for the collection was last executed. This information can be used for debugging compaction issues.
			Time time.Time `arango:"time,omitempty" json:"time,omitempty"`
		} `arango:"compactionStatus" json:"compactionStatus"`
		Compactors struct {
			// The number of compactor files.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The total filesize of all compactor files (in bytes).
			FileSize int64 `arango:"fileSize,omitempty" json:"fileSize,omitempty"`
		} `arango:"compactors" json:"compactors"`
		Dead struct {
			// The number of dead documents. This includes document versions that have been deleted or replaced by a newer version. Documents deleted or replaced that are contained the write-ahead log only are not reported in this figure.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The total number of deletion markers. Deletion markers only contained in the write-ahead log are not reporting in this figure.
			Deletion int64 `arango:"deletion,omitempty" json:"deletion,omitempty"`
			// The total size in bytes used by all dead documents.
			Size int64 `arango:"size,omitempty" json:"size,omitempty"`
		} `arango:"dead" json:"dead"`
		Indexes struct {
			// The total number of indexes defined for the collection, including the pre-defined indexes (e.g. primary index).
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The total memory allocated for indexes in bytes.
			Size int64 `arango:"size,omitempty" json:"size,omitempty"`
		} `arango:"indexes" json:"indexes"`
		ReadCache struct {
			// The number of revisions of this collection stored in the document revisions cache.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The memory used for storing the revisions of this collection in the document revisions cache (in bytes). This figure does not include the document data but only mappings from document revision ids to cache entry locations.
			Size int64 `arango:"size,omitempty" json:"size,omitempty"`
		} `arango:"readcache" json:"readcache"`
		// An optional string value that contains information about which object type is at the head of the collection's cleanup queue. This information can be used for debugging compaction and unload issues.
		WaitingFor string `arango:"waitingFor,omitempty" json:"waitingFor,omitempty"`
		Alive      struct {
			// The number of currently active documents in all datafiles and journals of the collection. Documents that are contained in the write-ahead log only are not reported in this figure.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The total size in bytes used by all active documents of the collection. Documents that are contained in the write-ahead log only are not reported in this figure.
			Size int64 `arango:"size,omitempty" json:"size,omitempty"`
		} `arango:"alive" json:"alive"`
		// The tick of the last marker that was stored in a journal of the collection. This might be 0 if the collection does not yet have a journal.
		LastTick int64 `arango:"lastTick,omitempty" json:"lastTick,omitempty"`
		Journals struct {
			// The number of journal files.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The total filesize of all journal files (in bytes).
			FileSize int64 `arango:"fileSize,omitempty" json:"fileSize,omitempty"`
		} `arango:"journals" json:"journals"`
		Revisions struct {
			// The number of revisions of this collection managed by the storage engine.
			Count int64 `arango:"count,omitempty" json:"count,omitempty"`
			// The memory used for storing the revisions of this collection in the storage engine (in bytes). This figure does not include the document data but only mappings from document revision ids to storage engine datafile positions.
			Size int64 `arango:"size,omitempty" json:"size,omitempty"`
		} `arango:"revisions" json:"revisions"`
	} `arango:"figures" json:"figures"`
}

CollectionStatistics contains the number of documents and additional statistical information about a collection.

type CollectionStatus

type CollectionStatus int

CollectionStatus indicates the status of a collection.

type CollectionType

type CollectionType int

CollectionType is the type of a collection.

type Connection

type Connection interface {
	// NewRequest creates a new request with given method and path.
	NewRequest(method, path string) (Request, error)

	// Do performs a given request, returning its response.
	Do(ctx context.Context, req Request) (Response, error)

	// Unmarshal unmarshals the given raw object into the given result interface.
	Unmarshal(data RawObject, result interface{}) error

	// Endpoints returns the endpoints used by this connection.
	Endpoints() []string

	// UpdateEndpoints reconfigures the connection to use the given endpoints.
	UpdateEndpoints(endpoints []string) error

	// Configure the authentication used for this connection.
	SetAuthentication(Authentication) (Connection, error)

	// Protocols returns all protocols used by this connection.
	Protocols() ProtocolSet
}

Connection is a connenction to a database server using a specific protocol.

type ContentType

type ContentType int

ContentType identifies the type of encoding to use for the data.

const (
	// ContentTypeJSON encodes data as json
	ContentTypeJSON ContentType = iota
	// ContentTypeVelocypack encodes data as Velocypack
	ContentTypeVelocypack
)

func (ContentType) String

func (ct ContentType) String() string

type ContextKey

type ContextKey string

ContextKey is an internal type used for holding values in a `context.Context` do not use!.

type CreateCollectionOptions

type CreateCollectionOptions struct {
	// The maximal size of a journal or datafile in bytes. The value must be at least 1048576 (1 MiB). (The default is a configuration parameter)
	JournalSize int `arango:"journalSize,omitempty" json:"journalSize,omitempty"`
	// ReplicationFactor in a cluster (default is 1), this attribute determines how many copies of each shard are kept on different DBServers.
	// The value 1 means that only one copy (no synchronous replication) is kept.
	// A value of k means that k-1 replicas are kept. Any two copies reside on different DBServers.
	// Replication between them is synchronous, that is, every write operation to the "leader" copy will be replicated to all "follower" replicas,
	// before the write operation is reported successful. If a server fails, this is detected automatically
	// and one of the servers holding copies take over, usually without an error being reported.
	ReplicationFactor int `arango:"replicationFactor,omitempty" json:"replicationFactor,omitempty"`
	// If true then the data is synchronized to disk before returning from a document create, update, replace or removal operation. (default: false)
	WaitForSync bool `arango:"waitForSync,omitempty" json:"waitForSync,omitempty"`
	// Whether or not the collection will be compacted (default is true)
	DoCompact *bool `arango:"doCompact,omitempty" json:"doCompact,omitempty"`
	// If true then the collection data is kept in-memory only and not made persistent.
	// Unloading the collection will cause the collection data to be discarded. Stopping or re-starting the server will also
	// cause full loss of data in the collection. Setting this option will make the resulting collection be slightly faster
	// than regular collections because ArangoDB does not enforce any synchronization to disk and does not calculate any
	// CRC checksums for datafiles (as there are no datafiles). This option should therefore be used for cache-type collections only,
	// and not for data that cannot be re-created otherwise. (The default is false)
	IsVolatile bool `arango:"isVolatile,omitempty" json:"isVolatile,omitempty"`
	// In a cluster, this attribute determines which document attributes are used to
	// determine the target shard for documents. Documents are sent to shards based on the values of their shard key attributes.
	// The values of all shard key attributes in a document are hashed, and the hash value is used to determine the target shard.
	// Note: Values of shard key attributes cannot be changed once set. This option is meaningless in a single server setup.
	// The default is []string{"_key"}.
	ShardKeys []string `arango:"shardKeys,omitempty" json:"shardKeys,omitempty"`
	// In a cluster, this value determines the number of shards to create for the collection. In a single server setup, this option is meaningless. (default is 1)
	NumberOfShards int `arango:"numberOfShards,omitempty" json:"numberOfShards,omitempty"`
	// If true, create a system collection. In this case collection-name should start with an underscore.
	// End users should normally create non-system collections only. API implementors may be required to create system
	// collections in very special occasions, but normally a regular collection will do. (The default is false)
	IsSystem bool `arango:"isSystem,omitempty" json:"isSystem,omitempty"`
	// The type of the collection to create. (default is CollectionTypeDocument)
	Type CollectionType `arango:"type,omitempty" json:"type,omitempty"`
	// The number of buckets into which indexes using a hash table are split. The default is 16 and this number has to be a power
	// of 2 and less than or equal to 1024. For very large collections one should increase this to avoid long pauses when the hash
	// table has to be initially built or resized, since buckets are resized individually and can be initially built in parallel.
	// For example, 64 might be a sensible value for a collection with 100 000 000 documents.
	// Currently, only the edge index respects this value, but other index types might follow in future ArangoDB versions.
	// Changes are applied when the collection is loaded the next time.
	IndexBuckets int `arango:"indexBuckets,omitempty" json:"indexBuckets,omitempty"`
	// Specifies how keys in the collection are created.
	KeyOptions *CollectionKeyOptions `arango:"keyOptions,omitempty" json:"keyOptions,omitempty"`
	// This field is used for internal purposes only. DO NOT USE.
	DistributeShardsLike string `arango:"distributeShardsLike,omitempty" json:"distributeShardsLike,omitempty"`
	// Set to create a smart edge or vertex collection.
	// This requires ArangoDB Enterprise Edition.
	IsSmart bool `arango:"isSmart,omitempty" json:"isSmart,omitempty"`
	// This field must be set to the attribute that will be used for sharding or smart graphs.
	// All vertices are required to have this attribute set. Edges derive the attribute from their connected vertices.
	// This requires ArangoDB Enterprise Edition.
	SmartGraphAttribute string `arango:"smartGraphAttribute,omitempty" json:"smartGraphAttribute,omitempty"`
	// SmartJoinAttribute
	// In the specific case that the two collections have the same number of shards, the data of the two collections can
	// be co-located on the same server for the same shard key values. In this case the extra hop via the coordinator will not be necessary.
	// See documentation for smart joins.
	// This requires ArangoDB Enterprise Edition.
	SmartJoinAttribute string `arango:"smartJoinAttribute,omitempty" json:"smartJoinAttribute,omitempty"`
	// This attribute specifies the name of the sharding strategy to use for the collection.
	// Must be one of ShardingStrategy* values.
	ShardingStrategy ShardingStrategy `arango:"shardingStrategy,omitempty" json:"shardingStrategy,omitempty"`
}

CreateCollectionOptions contains options that customize the creating of a collection.

type CreateDatabaseOptions

type CreateDatabaseOptions struct {
	// List of users to initially create for the new database. User information will not be changed for users that already exist.
	// If users is not specified or does not contain any users, a default user root will be created with an empty string password.
	// This ensures that the new database will be accessible after it is created.
	Users []CreateDatabaseUserOptions `arango:"users,omitempty" json:"users,omitempty"`
}

CreateDatabaseOptions contains options that customize the creating of a database.

type CreateDatabaseUserOptions

type CreateDatabaseUserOptions struct {
	// Loginname of the user to be created
	UserName string `arango:"user,omitempty" json:"user,omitempty"`
	// The user password as a string. If not specified, it will default to an empty string.
	Password string `arango:"passwd,omitempty" json:"passwd,omitempty"`
	// A flag indicating whether the user account should be activated or not. The default value is true. If set to false, the user won't be able to log into the database.
	Active *bool `arango:"active,omitempty" json:"active,omitempty"`
	// A JSON object with extra user information. The data contained in extra will be stored for the user but not be interpreted further by ArangoDB.
	Extra interface{} `arango:"extra,omitempty" json:"extra,omitempty"`
}

CreateDatabaseUserOptions contains options for creating a single user for a database.

type CreateGraphOptions

type CreateGraphOptions struct {
	// OrphanVertexCollections is an array of additional vertex collections used in the graph.
	// These are vertices for which there are no edges linking these vertices with anything.
	OrphanVertexCollections []string
	// EdgeDefinitions is an array of edge definitions for the graph.
	EdgeDefinitions []EdgeDefinition
	// IsSmart defines if the created graph should be smart.
	// This only has effect in Enterprise Edition.
	IsSmart bool
	// SmartGraphAttribute is the attribute name that is used to smartly shard the vertices of a graph.
	// Every vertex in this Graph has to have this attribute.
	// Cannot be modified later.
	SmartGraphAttribute string
	// NumberOfShards is the number of shards that is used for every collection within this graph.
	// Cannot be modified later.
	NumberOfShards int
}

CreateGraphOptions contains options that customize the creating of a graph.

type Cursor

type Cursor interface {
	io.Closer

	// HasMore returns true if the next call to ReadDocument does not return a NoMoreDocuments error.
	HasMore() bool

	// ReadDocument reads the next document from the cursor.
	// The document data is stored into result, the document meta data is returned.
	// If the cursor has no more documents, a NoMoreDocuments error is returned.
	// Note: If the query (resulting in this cursor) does not return documents,
	//       then the returned DocumentMeta will be empty.
	ReadDocument(ctx context.Context, result interface{}) (DocumentMeta, error)

	// Count returns the total number of result documents available.
	// A valid return value is only available when the cursor has been created with a context that was
	// prepared with `WithQueryCount` and not with `WithQueryStream`.
	Count() int64

	// Statistics returns the query execution statistics for this cursor.
	// This might not be valid if the cursor has been created with a context that was
	// prepared with `WithQueryStream`
	Statistics() QueryStatistics
}

Cursor is returned from a query, used to iterate over a list of documents. Note that a Cursor must always be closed to avoid holding on to resources in the server while they are no longer needed.

type Database

type Database interface {
	// Name returns the name of the database.
	Name() string

	// Info fetches information about the database.
	Info(ctx context.Context) (DatabaseInfo, error)

	// EngineInfo returns information about the database engine being used.
	// Note: When your cluster has multiple endpoints (cluster), you will get information
	// from the server that is currently being used.
	// If you want to know exactly which server the information is from, use a client
	// with only a single endpoint and avoid automatic synchronization of endpoints.
	EngineInfo(ctx context.Context) (EngineInfo, error)

	// Remove removes the entire database.
	// If the database does not exist, a NotFoundError is returned.
	Remove(ctx context.Context) error

	// Collection functions
	DatabaseCollections

	// View functions
	DatabaseViews

	// Graph functions
	DatabaseGraphs

	// Query performs an AQL query, returning a cursor used to iterate over the returned documents.
	// Note that the returned Cursor must always be closed to avoid holding on to resources in the server while they are no longer needed.
	Query(ctx context.Context, query string, bindVars map[string]interface{}) (Cursor, error)

	// ValidateQuery validates an AQL query.
	// When the query is valid, nil returned, otherwise an error is returned.
	// The query is not executed.
	ValidateQuery(ctx context.Context, query string) error

	// Transaction performs a javascript transaction. The result of the transaction function is returned.
	Transaction(ctx context.Context, action string, options *TransactionOptions) (interface{}, error)
}

Database provides access to all collections & graphs in a single database.

type DatabaseCollections

type DatabaseCollections interface {
	// Collection opens a connection to an existing collection within the database.
	// If no collection with given name exists, an NotFoundError is returned.
	Collection(ctx context.Context, name string) (Collection, error)

	// CollectionExists returns true if a collection with given name exists within the database.
	CollectionExists(ctx context.Context, name string) (bool, error)

	// Collections returns a list of all collections in the database.
	Collections(ctx context.Context) ([]Collection, error)

	// CreateCollection creates a new collection with given name and options, and opens a connection to it.
	// If a collection with given name already exists within the database, a DuplicateError is returned.
	CreateCollection(ctx context.Context, name string, options *CreateCollectionOptions) (Collection, error)
}

DatabaseCollections provides access to all collections in a single database.

type DatabaseGraphs

type DatabaseGraphs interface {
	// Graph opens a connection to an existing graph within the database.
	// If no graph with given name exists, an NotFoundError is returned.
	Graph(ctx context.Context, name string) (Graph, error)

	// GraphExists returns true if a graph with given name exists within the database.
	GraphExists(ctx context.Context, name string) (bool, error)

	// Graphs returns a list of all graphs in the database.
	Graphs(ctx context.Context) ([]Graph, error)

	// CreateGraph creates a new graph with given name and options, and opens a connection to it.
	// If a graph with given name already exists within the database, a DuplicateError is returned.
	CreateGraph(ctx context.Context, name string, options *CreateGraphOptions) (Graph, error)
}

DatabaseGraphs provides access to all graphs in a single database.

type DatabaseInfo

type DatabaseInfo struct {
	// The identifier of the database.
	ID string `arango:"id,omitempty" json:"id,omitempty"`
	// The name of the database.
	Name string `arango:"name,omitempty" json:"name,omitempty"`
	// The filesystem path of the database.
	Path string `arango:"path,omitempty" json:"path,omitempty"`
	// If true then the database is the _system database.
	IsSystem bool `arango:"isSystem,omitempty" json:"isSystem,omitempty"`
}

DatabaseInfo contains information about a database

type DatabaseInventory

type DatabaseInventory struct {
	// Details of all collections
	Collections []InventoryCollection `json:"collections,omitempty"`
	// Details of all views
	Views []InventoryView `json:"views,omitempty"`
}

DatabaseInventory describes a detailed state of the collections & shards of a specific database within a cluster.

func (DatabaseInventory) CollectionByName

func (i DatabaseInventory) CollectionByName(name string) (InventoryCollection, bool)

CollectionByName returns the InventoryCollection with given name. Return false if not found.

func (DatabaseInventory) IsReady

func (i DatabaseInventory) IsReady() bool

IsReady returns true if the IsReady flag of all collections is set.

func (DatabaseInventory) PlanVersion

func (i DatabaseInventory) PlanVersion() int64

PlanVersion returns the plan version of the first collection in the given inventory.

func (DatabaseInventory) ViewByName

func (i DatabaseInventory) ViewByName(name string) (InventoryView, bool)

ViewByName returns the InventoryView with given name. Return false if not found.

type DatabaseViews

type DatabaseViews interface {
	// View opens a connection to an existing view within the database.
	// If no collection with given name exists, an NotFoundError is returned.
	View(ctx context.Context, name string) (View, error)

	// ViewExists returns true if a view with given name exists within the database.
	ViewExists(ctx context.Context, name string) (bool, error)

	// Views returns a list of all views in the database.
	Views(ctx context.Context) ([]View, error)

	// CreateArangoSearchView creates a new view of type ArangoSearch,
	// with given name and options, and opens a connection to it.
	// If a view with given name already exists within the database, a ConflictError is returned.
	CreateArangoSearchView(ctx context.Context, name string, options *ArangoSearchViewProperties) (ArangoSearchView, error)
}

DatabaseViews provides access to all views in a single database. Views are only available in ArangoDB 3.4 and higher.

type DocumentID

type DocumentID string

DocumentID references a document in a collection. Format: collection/_key

func NewDocumentID

func NewDocumentID(collection, key string) DocumentID

NewDocumentID creates a new document ID from the given collection, key pair.

func (DocumentID) Collection

func (id DocumentID) Collection() string

Collection returns the collection part of the ID.

func (DocumentID) IsEmpty

func (id DocumentID) IsEmpty() bool

IsEmpty returns true if the given ID is empty, false otherwise.

func (DocumentID) Key

func (id DocumentID) Key() string

Key returns the key part of the ID.

func (DocumentID) String

func (id DocumentID) String() string

String returns a string representation of the document ID.

func (DocumentID) Validate

func (id DocumentID) Validate() error

Validate validates the given id.

func (DocumentID) ValidateOrEmpty

func (id DocumentID) ValidateOrEmpty() error

ValidateOrEmpty validates the given id unless it is empty. In case of empty, nil is returned.

type DocumentMeta

type DocumentMeta struct {
	Key string     `arango:"_key,omitempty" json:"_key,omitempty"`
	ID  DocumentID `arango:"_id,omitempty" json:"_id,omitempty"`
	Rev string     `arango:"_rev,omitempty" json:"_rev,omitempty"`
}

DocumentMeta contains all meta data used to identifier a document.

type DocumentMetaSlice

type DocumentMetaSlice []DocumentMeta

DocumentMetaSlice is a slice of DocumentMeta elements

func (DocumentMetaSlice) IDs

func (l DocumentMetaSlice) IDs() []DocumentID

IDs returns the ID's of all elements.

func (DocumentMetaSlice) Keys

func (l DocumentMetaSlice) Keys() []string

Keys returns the keys of all elements.

func (DocumentMetaSlice) Revs

func (l DocumentMetaSlice) Revs() []string

Revs returns the revisions of all elements.

type EdgeDefinition

type EdgeDefinition struct {
	// The name of the edge collection to be used.
	Collection string `arango:"collection" json:"collection"`
	// To contains the names of one or more edge collections that can contain target vertices.
	To []string `arango:"to" json:"to"`
	// From contains the names of one or more vertex collections that can contain source vertices.
	From []string `arango:"from" json:"from"`
}

EdgeDefinition contains all information needed to define a single edge in a graph.

type EdgeDocument

type EdgeDocument struct {
	From DocumentID `arango:"_from,omitempty" json:"_from,omitempty"`
	To   DocumentID `arango:"_to,omitempty" json:"_to,omitempty"`
}

EdgeDocument is a minimal document for use in edge collection. You can use this in your own edge document structures completely use your own. If you use your own, make sure to include a `_from` and `_to` field.

type EngineInfo

type EngineInfo struct {
	Type EngineType `arango:"name" json:"name"`
}

EngineInfo contains information about the database engine being used.

type EngineType

type EngineType string

EngineType indicates type of database engine being used.

func (EngineType) String

func (t EngineType) String() string

type EnsureFullTextIndexOptions

type EnsureFullTextIndexOptions struct {
	// MinLength is the minimum character length of words to index. Will default to a server-defined
	// value if unspecified (0). It is thus recommended to set this value explicitly when creating the index.
	MinLength int
}

EnsureFullTextIndexOptions contains specific options for creating a full text index.

type EnsureGeoIndexOptions

type EnsureGeoIndexOptions struct {
	// If a geo-spatial index on a location is constructed and GeoJSON is true, then the order within the array
	// is longitude followed by latitude. This corresponds to the format described in http://geojson.org/geojson-spec.html#positions
	GeoJSON bool
}

EnsureGeoIndexOptions contains specific options for creating a geo index.

type EnsureHashIndexOptions

type EnsureHashIndexOptions struct {
	// If true, then create a unique index.
	Unique bool
	// If true, then create a sparse index.
	Sparse bool
	// If true, de-duplication of array-values, before being added to the index, will be turned off.
	// This flag requires ArangoDB 3.2.
	// Note: this setting is only relevant for indexes with array fields (e.g. "fieldName[*]")
	NoDeduplicate bool
}

EnsureHashIndexOptions contains specific options for creating a hash index.

type EnsurePersistentIndexOptions

type EnsurePersistentIndexOptions struct {
	// If true, then create a unique index.
	Unique bool
	// If true, then create a sparse index.
	Sparse bool
}

EnsurePersistentIndexOptions contains specific options for creating a persistent index.

type EnsureSkipListIndexOptions

type EnsureSkipListIndexOptions struct {
	// If true, then create a unique index.
	Unique bool
	// If true, then create a sparse index.
	Sparse bool
	// If true, de-duplication of array-values, before being added to the index, will be turned off.
	// This flag requires ArangoDB 3.2.
	// Note: this setting is only relevant for indexes with array fields (e.g. "fieldName[*]")
	NoDeduplicate bool
}

EnsureSkipListIndexOptions contains specific options for creating a skip-list index.

type ErrorSlice

type ErrorSlice []error

ErrorSlice is a slice of errors

func (ErrorSlice) FirstNonNil

func (l ErrorSlice) FirstNonNil() error

FirstNonNil returns the first error in the slice that is not nil. If all errors in the slice are nil, nil is returned.

type Grant

type Grant string

Grant specifies access rights for an object

const (
	// GrantReadWrite indicates read/write access to an object
	GrantReadWrite Grant = "rw"
	// GrantReadOnly indicates read-only access to an object
	GrantReadOnly Grant = "ro"
	// GrantNone indicates no access to an object
	GrantNone Grant = "none"
)

type Graph

type Graph interface {
	// Name returns the name of the graph.
	Name() string

	// Remove removes the entire graph.
	// If the graph does not exist, a NotFoundError is returned.
	Remove(ctx context.Context) error

	// Edge collection functions
	GraphEdgeCollections

	// Vertex collection functions
	GraphVertexCollections
}

Graph provides access to all edge & vertex collections of a single graph in a database.

type GraphEdgeCollections

type GraphEdgeCollections interface {
	// EdgeCollection opens a connection to an existing edge-collection within the graph.
	// If no edge-collection with given name exists, an NotFoundError is returned.
	// Note: When calling Remove on the returned Collection, the collection is removed from the graph. Not from the database.
	EdgeCollection(ctx context.Context, name string) (Collection, VertexConstraints, error)

	// EdgeCollectionExists returns true if an edge-collection with given name exists within the graph.
	EdgeCollectionExists(ctx context.Context, name string) (bool, error)

	// EdgeCollections returns all edge collections of this graph
	// Note: When calling Remove on any of the returned Collection's, the collection is removed from the graph. Not from the database.
	EdgeCollections(ctx context.Context) ([]Collection, []VertexConstraints, error)

	// CreateEdgeCollection creates an edge collection in the graph.
	// collection: The name of the edge collection to be used.
	// constraints.From: contains the names of one or more vertex collections that can contain source vertices.
	// constraints.To: contains the names of one or more edge collections that can contain target vertices.
	CreateEdgeCollection(ctx context.Context, collection string, constraints VertexConstraints) (Collection, error)

	// SetVertexConstraints modifies the vertex constraints of an existing edge collection in the graph.
	SetVertexConstraints(ctx context.Context, collection string, constraints VertexConstraints) error
}

GraphEdgeCollections provides access to all edge collections of a single graph in a database.

type GraphVertexCollections

type GraphVertexCollections interface {
	// VertexCollection opens a connection to an existing vertex-collection within the graph.
	// If no vertex-collection with given name exists, an NotFoundError is returned.
	// Note: When calling Remove on the returned Collection, the collection is removed from the graph. Not from the database.
	VertexCollection(ctx context.Context, name string) (Collection, error)

	// VertexCollectionExists returns true if an vertex-collection with given name exists within the graph.
	VertexCollectionExists(ctx context.Context, name string) (bool, error)

	// VertexCollections returns all vertex collections of this graph
	// Note: When calling Remove on any of the returned Collection's, the collection is removed from the graph. Not from the database.
	VertexCollections(ctx context.Context) ([]Collection, error)

	// CreateVertexCollection creates a vertex collection in the graph.
	// collection: The name of the vertex collection to be used.
	CreateVertexCollection(ctx context.Context, collection string) (Collection, error)
}

GraphVertexCollections provides access to all vertex collections of a single graph in a database.

type ImportDocumentOptions

type ImportDocumentOptions struct {
	// FromPrefix is an optional prefix for the values in _from attributes. If specified, the value is automatically
	// prepended to each _from input value. This allows specifying just the keys for _from.
	FromPrefix string `arango:"fromPrefix,omitempty" json:"fromPrefix,omitempty"`
	// ToPrefix is an optional prefix for the values in _to attributes. If specified, the value is automatically
	// prepended to each _to input value. This allows specifying just the keys for _to.
	ToPrefix string `arango:"toPrefix,omitempty" json:"toPrefix,omitempty"`
	// Overwrite is a flag that if set, then all data in the collection will be removed prior to the import.
	// Note that any existing index definitions will be preseved.
	Overwrite bool `arango:"overwrite,omitempty" json:"overwrite,omitempty"`
	// OnDuplicate controls what action is carried out in case of a unique key constraint violation.
	// Possible values are:
	// - ImportOnDuplicateError
	// - ImportOnDuplicateUpdate
	// - ImportOnDuplicateReplace
	// - ImportOnDuplicateIgnore
	OnDuplicate ImportOnDuplicate `arango:"onDuplicate,omitempty" json:"onDuplicate,omitempty"`
	// Complete is a flag that if set, will make the whole import fail if any error occurs.
	// Otherwise the import will continue even if some documents cannot be imported.
	Complete bool `arango:"complete,omitempty" json:"complete,omitempty"`
}

ImportDocumentOptions holds optional options that control the import document process.

type ImportDocumentStatistics

type ImportDocumentStatistics struct {
	// Created holds the number of documents imported.
	Created int64 `arango:"created,omitempty" json:"created,omitempty"`
	// Errors holds the number of documents that were not imported due to an error.
	Errors int64 `arango:"errors,omitempty" json:"errors,omitempty"`
	// Empty holds the number of empty lines found in the input (will only contain a value greater zero for types documents or auto).
	Empty int64 `arango:"empty,omitempty" json:"empty,omitempty"`
	// Updated holds the number of updated/replaced documents (in case onDuplicate was set to either update or replace).
	Updated int64 `arango:"updated,omitempty" json:"updated,omitempty"`
	// Ignored holds the number of failed but ignored insert operations (in case onDuplicate was set to ignore).
	Ignored int64 `arango:"ignored,omitempty" json:"ignored,omitempty"`
}

ImportDocumentStatistics holds statistics of an import action.

type ImportOnDuplicate

type ImportOnDuplicate string

ImportOnDuplicate is a type to control what action is carried out in case of a unique key constraint violation.

type Index

type Index interface {
	// Name returns the name of the index.
	Name() string

	// Type returns the type of the index
	Type() IndexType

	// Remove removes the entire index.
	// If the index does not exist, a NotFoundError is returned.
	Remove(ctx context.Context) error
}

Index provides access to a single index in a single collection.

type IndexType

type IndexType string

IndexType represents a index type as string

type InvalidArgumentError

type InvalidArgumentError struct {
	Message string
}

InvalidArgumentError is returned when a go function argument is invalid.

func (InvalidArgumentError) Error

func (e InvalidArgumentError) Error() string

Error implements the error interface for InvalidArgumentError.

type InventoryCollection

type InventoryCollection struct {
	Parameters  InventoryCollectionParameters `json:"parameters"`
	Indexes     []InventoryIndex              `json:"indexes,omitempty"`
	PlanVersion int64                         `json:"planVersion,omitempty"`
	IsReady     bool                          `json:"isReady,omitempty"`
	AllInSync   bool                          `json:"allInSync,omitempty"`
}

InventoryCollection is a single element of a DatabaseInventory, containing all information of a specific collection.

func (InventoryCollection) IndexByFieldsAndType

func (i InventoryCollection) IndexByFieldsAndType(fields []string, indexType string) (InventoryIndex, bool)

IndexByFieldsAndType returns the InventoryIndex with given fields & type. Return false if not found.

type InventoryCollectionParameters

type InventoryCollectionParameters struct {
	Deleted             bool             `json:"deleted,omitempty"`
	DoCompact           bool             `json:"doCompact,omitempty"`
	ID                  string           `json:"id,omitempty"`
	IndexBuckets        int              `json:"indexBuckets,omitempty"`
	Indexes             []InventoryIndex `json:"indexes,omitempty"`
	IsSmart             bool             `json:"isSmart,omitempty"`
	SmartGraphAttribute string           `json:"smartGraphAttribute,omitempty"`
	IsSystem            bool             `json:"isSystem,omitempty"`
	IsVolatile          bool             `json:"isVolatile,omitempty"`
	JournalSize         int64            `json:"journalSize,omitempty"`
	KeyOptions          struct {
		Type          string `json:"type,omitempty"`
		AllowUserKeys bool   `json:"allowUserKeys,omitempty"`
		LastValue     int64  `json:"lastValue,omitempty"`
	} `json:"keyOptions"`
	Name                 string                 `json:"name,omitempty"`
	NumberOfShards       int                    `json:"numberOfShards,omitempty"`
	Path                 string                 `json:"path,omitempty"`
	PlanID               string                 `json:"planId,omitempty"`
	ReplicationFactor    int                    `json:"replicationFactor,omitempty"`
	ShardKeys            []string               `json:"shardKeys,omitempty"`
	Shards               map[ShardID][]ServerID `json:"shards,omitempty"`
	Status               CollectionStatus       `json:"status,omitempty"`
	Type                 CollectionType         `json:"type,omitempty"`
	WaitForSync          bool                   `json:"waitForSync,omitempty"`
	DistributeShardsLike string                 `json:"distributeShardsLike,omitempty"`
	SmartJoinAttribute   string                 `json:"smartJoinAttribute,omitempty"`
	ShardingStrategy     ShardingStrategy       `json:"shardingStrategy,omitempty"`
}

InventoryCollectionParameters contains all configuration parameters of a collection in a database inventory.

func (*InventoryCollectionParameters) IsSatellite

func (icp *InventoryCollectionParameters) IsSatellite() bool

IsSatellite returns true if the collection is a satellite collection

func (*InventoryCollectionParameters) MarshalJSON

func (p *InventoryCollectionParameters) MarshalJSON() ([]byte, error)

MarshalJSON converts InventoryCollectionParameters into json

func (*InventoryCollectionParameters) UnmarshalJSON

func (p *InventoryCollectionParameters) UnmarshalJSON(d []byte) error

UnmarshalJSON loads InventoryCollectionParameters from json

type InventoryIndex

type InventoryIndex struct {
	ID          string   `json:"id,omitempty"`
	Type        string   `json:"type,omitempty"`
	Fields      []string `json:"fields,omitempty"`
	Unique      bool     `json:"unique"`
	Sparse      bool     `json:"sparse"`
	Deduplicate bool     `json:"deduplicate"`
	MinLength   int      `json:"minLength,omitempty"`
	GeoJSON     bool     `json:"geoJson,omitempty"`
}

InventoryIndex contains all configuration parameters of a single index of a collection in a database inventory.

func (InventoryIndex) FieldsEqual

func (i InventoryIndex) FieldsEqual(fields []string) bool

FieldsEqual returns true when the given fields list equals the Fields list in the InventoryIndex. The order of fields is irrelevant.

type InventoryView

type InventoryView struct {
	Name     string   `json:"name,omitempty"`
	Deleted  bool     `json:"deleted,omitempty"`
	ID       string   `json:"id,omitempty"`
	IsSystem bool     `json:"isSystem,omitempty"`
	PlanID   string   `json:"planId,omitempty"`
	Type     ViewType `json:"type,omitempty"`
	// Include all properties from an arangosearch view.
	ArangoSearchViewProperties
}

InventoryView is a single element of a DatabaseInventory, containing all information of a specific view.

type KeyGeneratorType

type KeyGeneratorType string

KeyGeneratorType is a type of key generated, used in `CollectionKeyOptions`.

type NoMoreDocumentsError

type NoMoreDocumentsError struct{}

NoMoreDocumentsError is returned by Cursor's, when an attempt is made to read documents when there are no more.

func (NoMoreDocumentsError) Error

func (e NoMoreDocumentsError) Error() string

Error implements the error interface for NoMoreDocumentsError.

type NumberOfServersResponse

type NumberOfServersResponse struct {
	NoCoordinators   int      `json:"numberOfCoordinators,omitempty"`
	NoDBServers      int      `json:"numberOfDBServers,omitempty"`
	CleanedServerIDs []string `json:"cleanedServers,omitempty"`
}

NumberOfServersResponse holds the data returned from a NumberOfServer request.

type Protocol

type Protocol int
const (
	ProtocolHTTP Protocol = iota
	ProtocolVST1_0
	ProtocolVST1_1
)

type ProtocolSet

type ProtocolSet []Protocol

ProtocolSet is a set of protocols.

func (ProtocolSet) Contains

func (ps ProtocolSet) Contains(p Protocol) bool

Contains returns true if the given protocol is contained in the given set, false otherwise.

func (ProtocolSet) ContainsAny

func (ps ProtocolSet) ContainsAny(p ...Protocol) bool

ContainsAny returns true if any of the given protocols is contained in the given set, false otherwise.

type QueryStatistics

type QueryStatistics interface {
	// the total number of data-modification operations successfully executed.
	WritesExecuted() int64
	// The total number of data-modification operations that were unsuccessful
	WritesIgnored() int64
	// The total number of documents iterated over when scanning a collection without an index.
	ScannedFull() int64
	// The total number of documents iterated over when scanning a collection using an index.
	ScannedIndex() int64
	// the total number of documents that were removed after executing a filter condition in a FilterNode
	Filtered() int64
	// Returns the numer of results before the last LIMIT in the query was applied.
	// A valid return value is only available when the has been created with a context that was
	// prepared with `WithFullCount`. Additionally this will also not return a valid value if
	// the context was prepared with `WithStream`.
	FullCount() int64
	// Execution time of the query (wall-clock time). value will be set from the outside
	ExecutionTime() time.Duration
}

Statistics returned with the query cursor

type RawObject

type RawObject []byte

RawObject is a raw encoded object. Connection implementations must be able to unmarshal *RawObject into Go objects.

func (*RawObject) MarshalJSON

func (r *RawObject) MarshalJSON() ([]byte, error)

MarshalJSON returns *r as the JSON encoding of r.

func (RawObject) MarshalVPack

func (r RawObject) MarshalVPack() (velocypack.Slice, error)

MarshalVPack returns m as the Velocypack encoding of m.

func (*RawObject) UnmarshalJSON

func (r *RawObject) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *r to a copy of data.

func (*RawObject) UnmarshalVPack

func (r *RawObject) UnmarshalVPack(data velocypack.Slice) error

UnmarshalVPack sets *m to a copy of data.

type Replication

type Replication interface {
	// CreateBatch creates a "batch" to prevent removal of state required for replication
	CreateBatch(ctx context.Context, db Database, serverID int64, ttl time.Duration) (Batch, error)
	// Get the inventory of the server containing all collections (with entire details) of a database.
	// When this function is called on a coordinator is a cluster, an ID of a DBServer must be provided
	// using a context that is prepare with `WithDBServerID`.
	DatabaseInventory(ctx context.Context, db Database) (DatabaseInventory, error)
}

Replication provides access to replication related operations.

type Request

type Request interface {
	// SetQuery sets a single query argument of the request.
	// Any existing query argument with the same key is overwritten.
	SetQuery(key, value string) Request
	// SetBody sets the content of the request.
	// The protocol of the connection determines what kinds of marshalling is taking place.
	// When multiple bodies are given, they are merged, with fields in the first document prevailing.
	SetBody(body ...interface{}) (Request, error)
	// SetBodyArray sets the content of the request as an array.
	// If the given mergeArray is not nil, its elements are merged with the elements in the body array (mergeArray data overrides bodyArray data).
	// The merge is NOT recursive.
	// The protocol of the connection determines what kinds of marshalling is taking place.
	SetBodyArray(bodyArray interface{}, mergeArray []map[string]interface{}) (Request, error)
	// SetBodyImportArray sets the content of the request as an array formatted for importing documents.
	// The protocol of the connection determines what kinds of marshalling is taking place.
	SetBodyImportArray(bodyArray interface{}) (Request, error)
	// SetHeader sets a single header arguments of the request.
	// Any existing header argument with the same key is overwritten.
	SetHeader(key, value string) Request
	// Written returns true as soon as this request has been written completely to the network.
	// This does not guarantee that the server has received or processed the request.
	Written() bool
	// Clone creates a new request containing the same data as this request
	Clone() Request
	// Path returns the Request path
	Path() string
	// Method returns the Request method
	Method() string
}

Request represents the input to a request on the server.

type Response

type Response interface {
	// StatusCode returns an HTTP compatible status code of the response.
	StatusCode() int
	// Endpoint returns the endpoint that handled the request.
	Endpoint() string
	// CheckStatus checks if the status of the response equals to one of the given status codes.
	// If so, nil is returned.
	// If not, an attempt is made to parse an error response in the body and an error is returned.
	CheckStatus(validStatusCodes ...int) error
	// Header returns the value of a response header with given key.
	// If no such header is found, an empty string is returned.
	// On nested Response's, this function will always return an empty string.
	Header(key string) string
	// ParseBody performs protocol specific unmarshalling of the response data into the given result.
	// If the given field is non-empty, the contents of that field will be parsed into the given result.
	// This can only be used for requests that return a single object.
	ParseBody(field string, result interface{}) error
	// ParseArrayBody performs protocol specific unmarshalling of the response array data into individual response objects.
	// This can only be used for requests that return an array of objects.
	ParseArrayBody() ([]Response, error)
}

Response represents the response from the server on a given request.

type ResponseError

type ResponseError struct {
	Err error
}

A ResponseError is returned when a request was completely written to a server, but the server did not respond, or some kind of network error occurred during the response.

func (*ResponseError) Error

func (e *ResponseError) Error() string

Error returns the Error() result of the underlying error.

type ServerHealth

type ServerHealth struct {
	Endpoint            string           `json:"Endpoint"`
	LastHeartbeatAcked  time.Time        `json:"LastHeartbeatAcked"`
	LastHeartbeatSent   time.Time        `json:"LastHeartbeatSent"`
	LastHeartbeatStatus string           `json:"LastHeartbeatStatus"`
	Role                ServerRole       `json:"Role"`
	ShortName           string           `json:"ShortName"`
	Status              ServerStatus     `json:"Status"`
	CanBeDeleted        bool             `json:"CanBeDeleted"`
	HostID              string           `json:"Host,omitempty"`
	Version             Version          `json:"Version,omitempty"`
	Engine              EngineType       `json:"Engine,omitempty"`
	SyncStatus          ServerSyncStatus `json:"SyncStatus,omitempty"`

	// Only for Coordinators
	AdvertisedEndpoint *string `json:"AdvertisedEndpoint,omitempty"`

	// Only for Agents
	Leader  *string `json:"Leader,omitempty"`
	Leading *bool   `json:"Leading,omitempty"`
}

ServerHealth contains health information of a single server in a cluster.

type ServerID

type ServerID string

ServerID identifies an arangod server in a cluster.

type ServerMode

type ServerMode string
const (
	// ServerModeDefault is the normal mode of the database in which read and write requests
	// are allowed.
	ServerModeDefault ServerMode = "default"
	// ServerModeReadOnly is the mode in which all modifications to th database are blocked.
	// Behavior is the same as user that has read-only access to all databases & collections.
	ServerModeReadOnly ServerMode = "readonly"
)

type ServerRole

type ServerRole string

ServerRole is the role of an arangod server

const (
	// ServerRoleSingle indicates that the server is a single-server instance
	ServerRoleSingle ServerRole = "Single"
	// ServerRoleSingleActive indicates that the server is a the leader of a single-server resilient pair
	ServerRoleSingleActive ServerRole = "SingleActive"
	// ServerRoleSinglePassive indicates that the server is a a follower of a single-server resilient pair
	ServerRoleSinglePassive ServerRole = "SinglePassive"
	// ServerRoleDBServer indicates that the server is a dbserver within a cluster
	ServerRoleDBServer ServerRole = "DBServer"
	// ServerRoleCoordinator indicates that the server is a coordinator within a cluster
	ServerRoleCoordinator ServerRole = "Coordinator"
	// ServerRoleAgent indicates that the server is an agent within a cluster
	ServerRoleAgent ServerRole = "Agent"
	// ServerRoleUndefined indicates that the role of the server cannot be determined
	ServerRoleUndefined ServerRole = "Undefined"
)

type ServerStatus

type ServerStatus string

ServerStatus describes the health status of a server

const (
	// ServerStatusGood indicates server is in good state
	ServerStatusGood ServerStatus = "GOOD"
	// ServerStatusBad indicates server has missed 1 heartbeat
	ServerStatusBad ServerStatus = "BAD"
	// ServerStatusFailed indicates server has been declared failed by the supervision, this happens after about 15s being bad.
	ServerStatusFailed ServerStatus = "FAILED"
)

type ServerSyncStatus

type ServerSyncStatus string

ServerSyncStatus describes the servers sync status

const (
	ServerSyncStatusUnknown   ServerSyncStatus = "UNKNOWN"
	ServerSyncStatusUndefined ServerSyncStatus = "UNDEFINED"
	ServerSyncStatusStartup   ServerSyncStatus = "STARTUP"
	ServerSyncStatusStopping  ServerSyncStatus = "STOPPING"
	ServerSyncStatusStopped   ServerSyncStatus = "STOPPED"
	ServerSyncStatusServing   ServerSyncStatus = "SERVING"
	ServerSyncStatusShutdown  ServerSyncStatus = "SHUTDOWN"
)

type SetCollectionPropertiesOptions

type SetCollectionPropertiesOptions struct {
	// If true then creating or changing a document will wait until the data has been synchronized to disk.
	WaitForSync *bool `arango:"waitForSync,omitempty" json:"waitForSync,omitempty"`
	// The maximal size of a journal or datafile in bytes. The value must be at least 1048576 (1 MB). Note that when changing the journalSize value, it will only have an effect for additional journals or datafiles that are created. Already existing journals or datafiles will not be affected.
	JournalSize int64 `arango:"journalSize,omitempty" json:"journalSize,omitempty"`
	// ReplicationFactor contains how many copies of each shard are kept on different DBServers.
	// Only available in cluster setup.
	ReplicationFactor int `arango:"replicationFactor,omitempty" json:"replicationFactor,omitempty"`
}

SetCollectionPropertiesOptions contains data for Collection.SetProperties.

func (*SetCollectionPropertiesOptions) MarshalJSON

func (p *SetCollectionPropertiesOptions) MarshalJSON() ([]byte, error)

MarshalJSON converts SetCollectionPropertiesOptions into arango

func (*SetCollectionPropertiesOptions) UnmarshalJSON

func (p *SetCollectionPropertiesOptions) UnmarshalJSON(d []byte) error

UnmarshalJSON loads SetCollectionPropertiesOptions from arango

type ShardID

type ShardID string

ShardID is an internal identifier of a specific shard

type ShardingStrategy

type ShardingStrategy string

ShardingStrategy describes the sharding strategy of a collection

const (
	ShardingStrategyCommunityCompat           ShardingStrategy = "community-compat"
	ShardingStrategyEnterpriseCompat          ShardingStrategy = "enterprise-compat"
	ShardingStrategyEnterpriseSmartEdgeCompat ShardingStrategy = "enterprise-smart-edge-compat"
	ShardingStrategyHash                      ShardingStrategy = "hash"
	ShardingStrategyEnterpriseHashSmartEdge   ShardingStrategy = "enterprise-hash-smart-edge"
)

type Tick

type Tick string

Tick is represent a place in either the Write-Ahead Log, journals and datafiles value reported by the server

type TransactionOptions

type TransactionOptions struct {
	// Transaction size limit in bytes. Honored by the RocksDB storage engine only.
	MaxTransactionSize int

	// An optional numeric value that can be used to set a timeout for waiting on collection
	// locks. If not specified, a default value will be used.
	// Setting lockTimeout to 0 will make ArangoDB not time out waiting for a lock.
	LockTimeout *int

	// An optional boolean flag that, if set, will force the transaction to write
	// all data to disk before returning.
	WaitForSync bool

	// Maximum number of operations after which an intermediate commit is performed
	// automatically. Honored by the RocksDB storage engine only.
	IntermediateCommitCount *int

	// Optional arguments passed to action.
	Params []interface{}

	// Maximum total size of operations after which an intermediate commit is
	// performed automatically. Honored by the RocksDB storage engine only.
	IntermediateCommitSize *int

	// Collections that the transaction reads from.
	ReadCollections []string

	// Collections that the transaction writes to.
	WriteCollections []string
}

TransactionOptions contains options that customize the transaction.

type User

type User interface {
	// Name returns the name of the user.
	Name() string

	//  Is this an active user?
	IsActive() bool

	// Is a password change for this user needed?
	IsPasswordChangeNeeded() bool

	// Get extra information about this user that was passed during its creation/update/replacement
	Extra(result interface{}) error

	// Remove removes the user.
	// If the user does not exist, a NotFoundError is returned.
	Remove(ctx context.Context) error

	// Update updates individual properties of the user.
	// If the user does not exist, a NotFoundError is returned.
	Update(ctx context.Context, options UserOptions) error

	// Replace replaces all properties of the user.
	// If the user does not exist, a NotFoundError is returned.
	Replace(ctx context.Context, options UserOptions) error

	// AccessibleDatabases returns a list of all databases that can be accessed (read/write or read-only) by this user.
	AccessibleDatabases(ctx context.Context) ([]Database, error)

	// SetDatabaseAccess sets the access this user has to the given database.
	// Pass a `nil` database to set the default access this user has to any new database.
	// This function requires ArangoDB 3.2 and up for access value `GrantReadOnly`.
	SetDatabaseAccess(ctx context.Context, db Database, access Grant) error

	// GetDatabaseAccess gets the access rights for this user to the given database.
	// Pass a `nil` database to get the default access this user has to any new database.
	// This function requires ArangoDB 3.2 and up.
	// By default this function returns the "effective" grant.
	// To return the "configured" grant, pass a context configured with `WithConfigured`.
	// This distinction is only relevant in ArangoDB 3.3 in the context of a readonly database.
	GetDatabaseAccess(ctx context.Context, db Database) (Grant, error)

	// RemoveDatabaseAccess removes the access this user has to the given database.
	// As a result the users access falls back to its default access.
	// If you remove default access (db==`nil`) for a user (and there are no specific access
	// rules for a database), the user's access falls back to no-access.
	// Pass a `nil` database to set the default access this user has to any new database.
	// This function requires ArangoDB 3.2 and up.
	RemoveDatabaseAccess(ctx context.Context, db Database) error

	// SetCollectionAccess sets the access this user has to a collection.
	// If you pass a `Collection`, it will set access for that collection.
	// If you pass a `Database`, it will set the default collection access for that database.
	// If you pass `nil`, it will set the default collection access for the default database.
	// This function requires ArangoDB 3.2 and up.
	SetCollectionAccess(ctx context.Context, col AccessTarget, access Grant) error

	// GetCollectionAccess gets the access rights for this user to the given collection.
	// If you pass a `Collection`, it will get access for that collection.
	// If you pass a `Database`, it will get the default collection access for that database.
	// If you pass `nil`, it will get the default collection access for the default database.
	// By default this function returns the "effective" grant.
	// To return the "configured" grant, pass a context configured with `WithConfigured`.
	// This distinction is only relevant in ArangoDB 3.3 in the context of a readonly database.
	GetCollectionAccess(ctx context.Context, col AccessTarget) (Grant, error)

	// RemoveCollectionAccess removes the access this user has to a collection.
	// If you pass a `Collection`, it will removes access for that collection.
	// If you pass a `Database`, it will removes the default collection access for that database.
	// If you pass `nil`, it will removes the default collection access for the default database.
	// This function requires ArangoDB 3.2 and up.
	RemoveCollectionAccess(ctx context.Context, col AccessTarget) error

	// GrantReadWriteAccess grants this user read/write access to the given database.
	//
	// Deprecated: use GrantDatabaseReadWriteAccess instead.
	GrantReadWriteAccess(ctx context.Context, db Database) error

	// RevokeAccess revokes this user access to the given database.
	//
	// Deprecated: use `SetDatabaseAccess(ctx, db, GrantNone)` instead.
	RevokeAccess(ctx context.Context, db Database) error
}

User provides access to a single user of a single server / cluster of servers.

type UserOptions

type UserOptions struct {
	// The user password as a string. If not specified, it will default to an empty string.
	Password string `arango:"passwd,omitempty" json:"passwd,omitempty"`
	// A flag indicating whether the user account should be activated or not. The default value is true. If set to false, the user won't be able to log into the database.
	Active *bool `arango:"active,omitempty" json:"active,omitempty"`
	// A JSON object with extra user information. The data contained in extra will be stored for the user but not be interpreted further by ArangoDB.
	Extra interface{} `arango:"extra,omitempty" json:"extra,omitempty"`
}

UserOptions contains options for creating a new user, updating or replacing a user.

type Version

type Version string

Version holds a server version string. The string has the format "major.minor.sub". Major and minor will be numeric, and sub may contain a number or a textual version.

func (Version) CompareTo

func (v Version) CompareTo(other Version) int

CompareTo returns an integer comparing two version. The result will be 0 if v==other, -1 if v < other, and +1 if v > other. If major & minor parts are equal and sub part is not a number, the sub part will be compared using lexicographical string comparison.

func (Version) Major

func (v Version) Major() int

Major returns the major part of the version E.g. "3.1.7" -> 3

func (Version) Minor

func (v Version) Minor() int

Minor returns the minor part of the version. E.g. "3.1.7" -> 1

func (Version) Sub

func (v Version) Sub() string

Sub returns the sub part of the version. E.g. "3.1.7" -> "7"

func (Version) SubInt

func (v Version) SubInt() (int, bool)

SubInt returns the sub part of the version as integer. The bool return value indicates if the sub part is indeed a number. E.g. "3.1.7" -> 7, true E.g. "3.1.foo" -> 0, false

type VersionInfo

type VersionInfo struct {
	// This will always contain "arango"
	Server string `arango:"server,omitempty" json:"server,omitempty"`
	//  The server version string. The string has the format "major.minor.sub".
	// Major and minor will be numeric, and sub may contain a number or a textual version.
	Version Version `arango:"version,omitempty" json:"version,omitempty"`
	// Type of license of the server
	License string `arango:"license,omitempty" json:"license,omitempty"`
	// Optional additional details. This is returned only if the context is configured using WithDetails.
	Details map[string]interface{} `arango:"details,omitempty" json:"details,omitempty"`
}

VersionInfo describes the version of a database server.

func (*VersionInfo) IsEnterprise

func (v *VersionInfo) IsEnterprise() bool

func (VersionInfo) String

func (v VersionInfo) String() string

String creates a string representation of the given VersionInfo.

type VertexConstraints

type VertexConstraints struct {
	// From contains names of vertex collection that are allowed to be used in the From part of an edge.
	From []string
	// To contains names of vertex collection that are allowed to be used in the To part of an edge.
	To []string
}

VertexConstraints limit the vertex collection you can use in an edge.

type View

type View interface {
	// Name returns the name of the view.
	Name() string

	// Type returns the type of this view.
	Type() ViewType

	// ArangoSearchView returns this view as an ArangoSearch view.
	// When the type of the view is not ArangoSearch, an error is returned.
	ArangoSearchView() (ArangoSearchView, error)

	// Database returns the database containing the view.
	Database() Database

	// Remove removes the entire view.
	// If the view does not exist, a NotFoundError is returned.
	Remove(ctx context.Context) error
}

View provides access to the information of a view. Views are only available in ArangoDB 3.4 and higher.

type ViewType

type ViewType string

ViewType is the type of a view.

Directories

Path Synopsis
Package agency provides an API to access the ArangoDB agency (it is unlikely that you need this package directly).
Package agency provides an API to access the ArangoDB agency (it is unlikely that you need this package directly).
Package cluster implements a driver.Connection that provides cluster failover support (it is not intended to be used directly).
Package cluster implements a driver.Connection that provides cluster failover support (it is not intended to be used directly).
Package http implements driver.Connection using an HTTP connection.
Package http implements driver.Connection using an HTTP connection.
internal
json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package jwt provides a helper function used to access ArangoDB servers using a JWT secret.
Package jwt provides a helper function used to access ArangoDB servers using a JWT secret.
Package test implements add tests for the go-driver.
Package test implements add tests for the go-driver.
Package util provides some helper methods for the go-driver (it is unlikely that you need this package directly).
Package util provides some helper methods for the go-driver (it is unlikely that you need this package directly).
vst
Package vst implements driver.Connection using a VelocyStream connection.
Package vst implements driver.Connection using a VelocyStream connection.
protocol
Package protocol implements the VelocyStream protocol (it is not intended to be used directly).
Package protocol implements the VelocyStream protocol (it is not intended to be used directly).

Jump to

Keyboard shortcuts

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