Documentation
¶
Overview ¶
Package arangodb is a database/sql driver for ArangoDB, which runs AQL over the cursor API of HTTP. It registers the one name "arangodb", and takes a DSN of the form arangodb://user:pass@host:8529/database?key=value (D93).
db, err := sql.Open("arangodb", "arangodb://root:pass@localhost:8529/mydb")
The server binds each argument: sql.Named("k", v) fills @k, and a positional argument n fills @n, such as @1. A named argument that the query uses as @@k names a collection. Each query streams, one batch at a time, and with cancel=tag the driver stops it on the server when its context ends (D90). A stored document or edge is one column, and the keys of any other object are the columns (D89). A transaction names every collection of the database that is not a system collection (D91). The driver also takes CREATE and DROP of collections and indexes, which AQL does not have (D92). docs/ARANGODB.md holds what the driver knows about the server.
Index ¶
Constants ¶
const ( // CancelTag adds a line comment that names the connection and the query, // at the end of each query, or at the start of a long one (D99). It kills the query through /_api/query when // its context ends before the first batch, or when Close comes in the // first batch with more than 1 MiB of it left. It is the default. CancelTag = "tag" // CancelNone sends no comment, and a query in its first request runs on // to its end. CancelNone = "none" )
The values of the key cancel, which say how the driver stops a query on the server when its context ends (D90).
const ( // AuthBasic sends the user and the password with basic authentication. // It is the default. AuthBasic = "basic" // AuthBearer sends the password as a Bearer token, such as a JWT. AuthBearer = "bearer" )
The values of the key auth, which say how the driver sends the password (D94).
const Name = "arangodb"
Name is the name that the driver registers with database/sql, and the scheme of its DSN.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Host is the host of the server.
Host string
// Port is the port of the server, 8529 by default.
Port int
// TLS is true to speak HTTPS.
TLS bool
// User and Password are the credentials. The password can be a token
// (D94).
User string
Password string
// Database is the database, _system by default.
Database string
// Cancel is CancelTag or CancelNone (D90).
Cancel string
// Batch is the batchSize of each cursor, 1000 by default.
Batch int
// Auth is AuthBasic or AuthBearer (D94).
Auth string
}
Config is the configuration of a connector, which the DSN holds. The caller owns it (D7).
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector opens connections to one database. It owns its transport, and every connection shares it. A caller can build one from a Config and open it with sql.OpenDB.
func NewConnector ¶
NewConnector returns a Connector for cfg. The connector keeps a copy of cfg, and fills each field that is zero with its default.
type Driver ¶
type Driver struct{}
Driver is the database/sql driver for ArangoDB.
type Error ¶
type Error struct {
// HTTPStatus is the status code of the response.
HTTPStatus int
// Num is the errorNum of the server, or 0 when the body held none.
Num int
// Message is the errorMessage of the server.
Message string
// contains filtered or unexported fields
}
Error is an error that ArangoDB reported, with its HTTP status and its errorNum, such as 1501 for a statement that does not parse (measured). Compare Num, and not the message, as the vendor says.