This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
forked from arangodb/go-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.go
107 lines (88 loc) · 3.57 KB
/
database.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// 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
//
package driver
import "context"
// Database provides access to all collections & graphs in a single 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
// Streaming Transactions functions
DatabaseStreamingTransactions
// ArangoSearch Analyzers API
DatabaseArangoSearchAnalyzers
// 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)
}
// DatabaseInfo contains information about a database
type DatabaseInfo struct {
// The identifier of the database.
ID string `json:"id,omitempty"`
// The name of the database.
Name string `json:"name,omitempty"`
// The filesystem path of the database.
Path string `json:"path,omitempty"`
// If true then the database is the _system database.
IsSystem bool `json:"isSystem,omitempty"`
// Default replication factor for collections in database
ReplicationFactor int `json:"replicationFactor,omitempty"`
// Default write concern for collections in database
WriteConcern int `json:"writeConcern,omitempty"`
// Default sharding for collections in database
Sharding DatabaseSharding `json:"sharding,omitempty"`
}
// EngineType indicates type of database engine being used.
type EngineType string
const (
EngineTypeMMFiles = EngineType("mmfiles")
EngineTypeRocksDB = EngineType("rocksdb")
)
func (t EngineType) String() string {
return string(t)
}
// EngineInfo contains information about the database engine being used.
type EngineInfo struct {
Type EngineType `json:"name"`
}