1
0
Fork 0

Doc - Update java driver chapter (#5796)

This commit is contained in:
Vinay Pyati 2018-07-09 18:28:58 +02:00 committed by sleto-it
parent a6c3ce48a9
commit bc55b61d04
24 changed files with 2860 additions and 33 deletions

View File

@ -5,8 +5,7 @@
<table>
<tr><th>arangodb-java-driver</th><th>ArangoDB</th><th>network protocol</th><th>Java version</th></tr>
<tr><td>4.3.x</td><td>3.0.0+</td><td>VelocyStream, HTTP</td><td>1.6+</td></tr>
<tr><td>4.2.x</td><td>3.0.0+</td><td>VelocyStream, HTTP</td><td>1.6+</td></tr>
<tr><td>4.2.x+</td><td>3.0.0+</td><td>VelocyStream, HTTP</td><td>1.6+</td></tr>
<tr><td>4.1.x</td><td>3.1.0+</td><td>VelocyStream</td><td>1.6+</td></tr>
<tr><td>3.1.x</td><td>3.1.0+</td><td>HTTP</td><td>1.6+</td></tr>
<tr><td>3.0.x</td><td>3.0.x</td><td>HTTP</td><td>1.6+</td></tr>
@ -21,17 +20,18 @@ To add the driver to your project with maven, add the following code to your pom
(please use a driver with a version number compatible to your ArangoDB server's version):
ArangoDB 3.x.x
```XML
<dependencies>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>arangodb-java-driver</artifactId>
<version>4.3.0</version>
<version>4.6.0</version>
</dependency>
</dependencies>
```
If you want to test with a snapshot version (e.g. 4.3.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
If you want to test with a snapshot version (e.g. 4.6.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
```XML
<repositories>

View File

@ -0,0 +1,76 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Bulk importing documents
This function implements the
[HTTP API for bulk imports](../../../..//HTTP/BulkImports/index.html).
## ArangoCollection.importDocuments
```
ArangoCollection.importDocuments(Collection<?> values, DocumentImportOptions options) : DocumentImportEntity
```
```
ArangoCollection.importDocuments(String values, DocumentImportOptions options) : DocumentImportEntity
```
Bulk imports the given values into the collection.
**Arguments**
- **values**: `Collection<?>` or `String`
- `Collection<?>`: A list of Objects that will be stored as documents
- `String`: JSON-encoded array of objects that will be stored as documents
- **options**: `DocumentImportOptions`
- **fromPrefix**: `String`
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.
- **toPrefix**: `String`
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.
- **overwrite**: `Boolean`
If this parameter has a value of true, then all data in the collection will be removed prior to the import. Note that any existing index definitions will be preseved.
- **waitForSync**: `Boolean`
Wait until documents have been synced to disk before returning.
- **onDuplicate**: `OnDuplicate`
Controls what action is carried out in case of a unique key constraint violation. Possible values are:
- **error**: this will not import the current document because of the unique key constraint violation. This is the default setting.
- **update**: this 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.
- **replace**: this will replace an existing document in the database with the data specified in the request.
- **ignore**: this will not update an existing document and simply ignore the error caused by the unique key constraint violation. Note that update, replace and ignore will only work when the import document in the request contains the \_key attribute. update and replace may also fail because of secondary unique key constraint violations.
- **complete**: `Boolean`
If set to true, it will make the whole import fail if any error occurs. Otherwise the import will continue even if some documents cannot be imported.
- **details**: `Boolean`
If set to true, the result will include an attribute details with details about documents that could not be imported.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument doc1 = new BaseDocument();
BaseDocument doc2 = new BaseDocument();
BaseDocument doc3 = new BaseDocument();
collection.importDocuments(Arrays.asList(doc1, doc2, doc3), new DocumentImportOptions());
```

View File

@ -0,0 +1,278 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating the collection
These functions implement
[the HTTP API for modifying collections](../../../..//HTTP/Collection/Modifying.html).
## ArangoDatabase.createCollection
```
ArangoDatabase.createCollection(String name, CollectionCreateOptions options) : CollectionEntity
```
Creates a collection with the given _options_ for this collection's name, then returns collection information from the server.
**Arguments**
- **name**: `String`
The name of the collection
- **options**: `CollectionCreateOptions`
- **journalSize**: `Long`
The maximal size of a journal or datafile in bytes. The value must be at least 1048576 (1 MiB).
- **replicationFactor**: `Integer`
(The default is 1): in a cluster, 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.
- **satellite**: `Boolean`
If the true the collection is created as a satellite collection. In this case the _replicationFactor_ is ignored.
- **waitForSync**: `Boolean`
If true then the data is synchronized to disk before returning from a document create, update, replace or removal operation. (default: false)
- **doCompact**: `Boolean`
Whether or not the collection will be compacted (default is true)
- **isVolatile**: `Boolean`
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)
- **shardKeys**: `String...`
(The default is [ "_key" ]): 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.
- **numberOfShards**: `Integer`
(The default is 1): in a cluster, this value determines the number of shards to create for the collection. In a single server setup, this option is meaningless.
- **isSystem**: `Boolean`
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)
- **type**: `CollectionType`
(The default is _CollectionType#DOCUMENT_): the type of the collection to create.
- **indexBuckets**: `Integer`
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 (see below) are applied when the collection is loaded the next time.
- **distributeShardsLike**: `String`
(The default is ""): in an enterprise cluster, this attribute binds the specifics of sharding for the newly created collection to follow that of a specified existing collection. Note: Using this parameter has consequences for the prototype collection. It can no longer be dropped, before sharding imitating collections are dropped. Equally, backups and restores of imitating collections alone will generate warnings, which can be overridden, about missing sharding prototype.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
db.createCollection("potatos", new CollectionCreateOptions());
// the document collection "potatos" now exists
```
## ArangoCollection.create
```
ArangoCollection.create(CollectionCreateOptions options) : CollectionEntity
```
Creates a collection with the given _options_ for this collection's name, then returns collection information from the server.
Alternative for [ArangoDatabase.createCollection](#arangodatabasecreatecollection).
**Arguments**
- **options**: `CollectionCreateOptions`
- **journalSize**: `Long`
The maximal size of a journal or datafile in bytes. The value must be at least 1048576 (1 MiB).
- **replicationFactor**: `Integer`
(The default is 1): in a cluster, 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.
- **satellite**: `Boolean`
If the true the collection is created as a satellite collection. In this case the _replicationFactor_ is ignored.
- **waitForSync**: `Boolean`
If true then the data is synchronized to disk before returning from a document create, update, replace or removal operation. (default: false)
- **doCompact**: `Boolean`
Whether or not the collection will be compacted (default is true)
- **isVolatile**: `Boolean`
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)
- **shardKeys**: `String...`
(The default is [ "_key" ]): 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.
- **numberOfShards**: `Integer`
(The default is 1): in a cluster, this value determines the number of shards to create for the collection. In a single server setup, this option is meaningless.
- **isSystem**: `Boolean`
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)
- **type**: `CollectionType`
(The default is _CollectionType#DOCUMENT_): the type of the collection to create.
- **indexBuckets**: `Integer`
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 (see below) are applied when the collection is loaded the next time.
- **distributeShardsLike**: `String`
(The default is ""): in an enterprise cluster, this attribute binds the specifics of sharding for the newly created collection to follow that of a specified existing collection. Note: Using this parameter has consequences for the prototype collection. It can no longer be dropped, before sharding imitating collections are dropped. Equally, backups and restores of imitating collections alone will generate warnings, which can be overridden, about missing sharding prototype.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("potatos");
collection.create(new CollectionCreateOptions());
// the document collection "potatos" now exists
```
## ArangoCollection.load
```
ArangoCollection.load() : CollectionEntity
```
Tells the server to load the collection into memory.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
collection.load();
// the collection has now been loaded into memory
```
## ArangoCollection.unload
```
ArangoCollection.unload() : CollectionEntity
```
Tells the server to remove the collection from memory. This call does not delete any documents. You can use the collection afterwards; in which case it will be loaded into memory, again.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
collection.unload();
// the collection has now been unloaded from memory
```
## ArangoCollection.changeProperties
```
ArangoCollection.changeProperties(CollectionPropertiesOptions options) : CollectionPropertiesEntity
```
Changes the properties of the collection.
**Arguments**
- **options**: `CollectionPropertiesEntity`
For information on the _properties_ argument see
[the HTTP API for modifying collections](../../../..//HTTP/Collection/Modifying.html).
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
CollectionPropertiesEntity result = collection.changeProperties(new CollectionPropertiesEntity().waitForSync(true));
assertThat(result.getWaitForSync(), is(true));
// the collection will now wait for data being written to disk
// whenever a document is changed
```
## ArangoCollection.rename
```
ArangoCollection.rename(String newName) : CollectionEntity
```
Renames the collection
**Arguments**
- **newName**: `String`
The new name
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
CollectionEntity result = collection.rename("new-collection-name")
assertThat(result.getName(), is("new-collection-name");
// result contains additional information about the collection
```
## ArangoCollection.truncate
```
ArangoCollection.truncate() : CollectionEntity
```
Removes all documents from the collection, but leaves the indexes intact.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
collection.truncate();
// the collection "some-collection" is now empty
```
## ArangoCollection.drop
```
ArangoCollection.drop() : void
```
Deletes the collection from the database.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
collection.drop();
// the collection "some-collection" no longer exists
```

View File

@ -0,0 +1,491 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating documents
These functions implement the
[HTTP API for manipulating documents](../../../..//HTTP/Document/index.html).
## ArangoCollection.documentExists
```
ArangoCollection.documentExists(String key) : Boolean
```
Checks if the document exists by reading a single document head
**Arguments**
- **key**: `String`
The key of the document
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
Boolean exists = collection.documentExists("some-key");
```
## ArangoCollection.getDocument
```
ArangoCollection.getDocument(String key, Class<T> type, DocumentReadOptions options) : T
```
Retrieves the document with the given \_key from the collection.
**Arguments**
- **key**: `String`
The key of the document
- **type**: `Class<T>`
The type of the document (POJO class, `VPackSlice` or `String` for Json)
- **options**: `DocumentReadOptions`
- **ifNoneMatch**: `String`
Document revision must not contain If-None-Match
- **ifMatch**: `String`
Document revision must contain If-Match
- **catchException**: `Boolean`
Whether or not catch possible thrown exceptions
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument document = collection.getDocument("some-key", BaseDocument.class);
```
## ArangoCollection.getDocuments
```
ArangoCollection.getDocuments(Collection<String> keys, Class<T> type) : MultiDocumentEntity<T>
```
Retrieves multiple documents with the given \_key from the collection.
**Arguments**
- **keys**: `Collection<String>`
The key of the document
- **type**: `Class<T>`
The type of the document (POJO class, `VPackSlice` or `String` for Json)
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
Collection<String> keys = Arrays.asList("some-key", "some-other-key");
MultiDocumentEntity<BaseDocument> documents = collection.getDocuments(keys, BaseDocument.class);
```
## ArangoCollection.insertDocument
```
ArangoCollection.insertDocument(T value, DocumentCreateOptions options) : DocumentCreateEntity<T>
```
Creates a new document from the given document, unless there is already a document with the \_key given. If no \_key is given, a new unique \_key is generated automatically.
**Arguments**
- **value**: `T`
A representation of a single document (POJO, `VPackSlice` or `String` for Json)
- **options**: `DocumentCreateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **returnNew**: `Boolean`
Return additionally the complete new document under the attribute new in the result.
- **returnOld**: `Boolean`
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
- **overwrite**: `Boolean`
If set to true, the insert becomes a replace-insert. If a document with the same \_key already exists the new document is not rejected with unique constraint violated but will replace the old document.
- **silent**: `Boolean`
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument document = new BaseDocument();
document.addAttribute("some", "data");
collection.insertDocument(document, new DocumentCreateOptions());
```
## ArangoCollection.insertDocuments
```
ArangoCollection.insertDocuments(Collection<T> values, DocumentCreateOptions options) : MultiDocumentEntity<DocumentCreateEntity<T>>
```
Creates new documents from the given documents, unless there is already a document with the \_key given. If no \_key is given, a new unique \_key is generated automatically.
**Arguments**
- **values**: `Collection<T>`
A List of documents (POJO, `VPackSlice` or `String` for Json)
- **options**: `DocumentCreateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **returnNew**: `Boolean`
Return additionally the complete new document under the attribute new in the result.
- **returnOld**: `Boolean`
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
- **overwrite**: `Boolean`
If set to true, the insert becomes a replace-insert. If a document with the same \_key already exists the new document is not rejected with unique constraint violated but will replace the old document.
- **silent**: `Boolean`
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument doc1 = new BaseDocument();
BaseDocument doc2 = new BaseDocument();
BaseDocument doc3 = new BaseDocument();
collection.insertDocuments(Arrays.asList(doc1, doc2, doc3), new DocumentCreateOptions());
```
## ArangoCollection.replaceDocument
```
ArangoCollection.replaceDocument(String key, T value, DocumentReplaceOptions options) : DocumentUpdateEntity<T>
```
Replaces the document with _key_ with the one in the body, provided there is such a document and no precondition is violated.
**Arguments**
- **key**: `String`
The key of the document
- **value**: `T`
A representation of a single document (POJO, `VPackSlice` or `String` for Json)
- **options**: `DocumentReplaceOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ignoreRevs**: `Boolean`
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
- **ifMatch**: `String`
Replace a document based on target revision
- **returnNew**: `Boolean`
Return additionally the complete new document under the attribute new in the result.
- **returnOld**: `Boolean`
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
- **silent**: `Boolean`
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument document = new BaseDocument();
document.addAttribute("hello", "world");
DocumentCreateEntity<BaseDocument> info = collection.insertDocument(document);
document.addAttribute("hello", "world2");
collection.replaceDocument(info.getKey(), document, new DocumentReplaceOptions());
BaseDocument doc = collection.getDocument(info.getKey());
assertThat(doc.getAttribute("hello"), is("world2"));
```
## ArangoCollection.replaceDocuments
```
ArangoCollection.replaceDocuments(Collection<T> values, DocumentReplaceOptions options) : MultiDocumentEntity<DocumentUpdateEntity<T>>
```
Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the \_key attributes in the documents in values.
**Arguments**
- **values**: `Collection<T>`
A List of documents (POJO, `VPackSlice` or `String` for Json)
- **options**: `DocumentReplaceOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ignoreRevs**: `Boolean`
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
- **ifMatch**: `String`
Replace a document based on target revision
- **returnNew**: `Boolean`
Return additionally the complete new document under the attribute new in the result.
- **returnOld**: `Boolean`
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
- **silent**: `Boolean`
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument doc1 = new BaseDocument();
BaseDocument doc2 = new BaseDocument();
BaseDocument doc3 = new BaseDocument();
collection.insertDocuments(Arrays.asList(doc1, doc2, doc3));
// change values of doc1, doc2, doc3
collection.replaceDocuments(Arrays.asList(doc1, doc2, doc3), new DocumentReplaceOptions());
```
## ArangoCollection.updateDocument
```
ArangoCollection.updateDocument(String key, T value, DocumentUpdateOptions options) : DocumentUpdateEntity<T>
```
Updates the document with _key_ with the one in the body, provided there is such a document and no precondition is violated.
**Arguments**
- **key**: `String`
The key of the document
- **value**: `T`
A representation of a single document (POJO, `VPackSlice` or `String` for Json)
- **options**: `DocumentUpdateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ignoreRevs**: `Boolean`
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
- **ifMatch**: `String`
Replace a document based on target revision
- **returnNew**: `Boolean`
Return additionally the complete new document under the attribute new in the result.
- **returnOld**: `Boolean`
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
- **silent**: `Boolean`
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument document = new BaseDocument();
document.addAttribute("hello", "world");
DocumentCreateEntity<BaseDocument> info = collection.insertDocument(document);
document.addAttribute("hello", "world2");
collection.updateDocument(info.getKey(), document, new DocumentUpdateOptions());
BaseDocument doc = collection.getDocument(info.getKey());
assertThat(doc.getAttribute("hello"), is("world2"));
```
## ArangoCollection.updateDocuments
```
ArangoCollection.updateDocuments(Collection<T> values, DocumentUpdateOptions options) : MultiDocumentEntity<DocumentUpdateEntity<T>>
```
Updates multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the \_key attributes in the documents in values.
**Arguments**
- **values**: `Collection<T>`
A List of documents (POJO, `VPackSlice` or `String` for Json)
- **options**: `DocumentUpdateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ignoreRevs**: `Boolean`
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
- **ifMatch**: `String`
Replace a document based on target revision
- **returnNew**: `Boolean`
Return additionally the complete new document under the attribute new in the result.
- **returnOld**: `Boolean`
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
- **silent**: `Boolean`
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument doc1 = new BaseDocument();
BaseDocument doc2 = new BaseDocument();
BaseDocument doc3 = new BaseDocument();
collection.insertDocuments(Arrays.asList(doc1, doc2, doc3));
// change values of doc1, doc2, doc3
collection.updateDocuments(Arrays.asList(doc1, doc2, doc3), new DocumentUpdateOptions());
```
## ArangoCollection.deleteDocument
```
ArangoCollection.deleteDocument(String key) : DocumentDeleteEntity<Void>
```
Deletes the document with the given _key_ from the collection.
**Arguments**:
- **key**: `String`
The key of the document
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
BaseDocument document = new BaseDocument("some-key");
collection.insertDocument(document);
collection.deleteDocument("some-key");
// document 'some-collection/some-key' no longer exists
Boolean exists = collection.documentExists("some-key");
assertThat(exists, is(false));
```
## ArangoCollection.deleteDocuments
```
ArangoCollection.deleteDocuments(Collection<?> values) : MultiDocumentEntity<DocumentDeleteEntity<Void>>
```
Deletes multiple documents from the collection.
**Arguments**:
- **values**: `Collection<?>`
The keys of the documents or the documents themselves
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
collection.deleteDocuments(Arrays.asList("some-key", "some-other-key");
// documents 'some-collection/some-key' and 'some-collection/some-other-key' no longer exists
```

View File

@ -0,0 +1,246 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating indexes
These functions implement the
[HTTP API for manipulating indexes](../../../..//HTTP/Indexes/index.html).
## ArangoCollection.ensureHashIndex
```
ArangoCollection.ensureHashIndex(Iterable<String> fields, HashIndexOptions options) : IndexEntity
```
Creates a hash index for the collection if it does not already exist.
**Arguments**
- **fields**: `Iterable<String>`
A list of attribute paths
- **options**: `HashIndexOptions`
- **unique**: `Boolean`
If true, then create a unique index
- **sparse**: `Boolean`
If true, then create a sparse index
- **deduplicate**: `Boolean`
If false, the deduplication of array values is turned off.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
IndexEntity index = collection.ensureHashIndex(Arrays.asList("a", "b.c"));
// the index has been created with the handle `index.getId()`
```
## ArangoCollection.ensureSkipListIndex
```
ArangoCollection.ensureSkipListIndex(Iterable<String> fields, SkipListIndexOptions options) : IndexEntity
```
Creates a skip-list index for the collection if it does not already exist.
**Arguments**
- **fields**: `Iterable<String>`
A list of attribute paths
- **options**: `SkipListIndexOptions`
- **unique**: `Boolean`
If true, then create a unique index
- **sparse**: `Boolean`
If true, then create a sparse index
- **deduplicate**: `Boolean`
If false, the deduplication of array values is turned off.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
IndexEntity index = collection.ensureSkipListIndex(Arrays.asList("a", "b.c"));
// the index has been created with the handle `index.getId()`
```
## ArangoCollection.ensureGeoIndex
```
ArangoCollection.ensureGeoIndex(Iterable<String> fields, GeoIndexOptions options) : IndexEntity
```
Creates a geo index for the collection if it does not already exist.
**Arguments**
- **fields**: `Iterable<String>`
A list of attribute paths
- **options**: `GeoIndexOptions`
- **geoJson**: `Boolean`
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.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
IndexEntity index = collection.ensureGeoIndex(Arrays.asList("latitude", "longitude"));
// the index has been created with the handle `index.getId()`
```
## ArangoCollection.ensureFulltextIndex
```
ArangoCollection.ensureFulltextIndex(Iterable<String> fields, FulltextIndexOptions options) : IndexEntity
```
Creates a fulltext index for the collection if it does not already exist.
**Arguments**
- **fields**: `Iterable<String>`
A list of attribute paths
- **options**: `FulltextIndexOptions`
- **minLength**: `Integer`
Minimum character length of words to index. Will default to a server-defined value if unspecified. It is thus recommended to set this value explicitly when creating the index.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
IndexEntity index = collection.ensureFulltextIndex(Arrays.asList("description"));
// the index has been created with the handle `index.getId()`
```
## ArangoCollection.ensurePersistentIndex
```
ArangoCollection.ensurePersistentIndex(Iterable<String> fields, PersistentIndexOptions options) : IndexEntity
```
Creates a persistent index for the collection if it does not already exist.
**Arguments**
- **fields**: `Iterable<String>`
A list of attribute paths
- **options**: `PersistentIndexOptions`
- **unique**: `Boolean`
If true, then create a unique index
- **sparse**: `Boolean`
If true, then create a sparse index
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
IndexEntity index = collection.ensurePersistentIndex(Arrays.asList("a", "b.c"));
// the index has been created with the handle `index.getId()`
```
## ArangoCollection.getIndex
```
ArangoCollection.getIndex(String id) : IndexEntity
```
Fetches information about the index with the given _id_ and returns it.
**Arguments**
- **id**: `String`
The index-handle
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
IndexEntity index = collection.getIndex("some-index");
```
## ArangoCollection.getIndexes
```
ArangoCollection.getIndexes() : Collection<IndexEntity>
```
Fetches a list of all indexes on this collection.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
Collection<IndexEntity> indexes = collection.getIndexs();
```
## ArangoCollection.deleteIndex
```
ArangoCollection.deleteIndex(String id) : String
```
Deletes the index with the given _id_ from the collection.
**Arguments**
- **id**: `String`
The index-handle
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("some-collection");
collection.deleteIndex("some-index");
```

View File

@ -0,0 +1,104 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Collection API
These functions implement the
[HTTP API for collections](../../../..//HTTP/Collection/index.html).
The _ArangoCollection_ API is used for all collections, regardless of
their specific type (document/edge collection).
## Getting information about the collection
See
[the HTTP API documentation](../../../..//HTTP/Collection/Getting.html)
for details.
## ArangoCollection.exists
```
ArangoCollection.exists() : boolean
```
Checks whether the collection exists
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("potatos");
boolean exists = collection.exists();
```
## ArangoCollection.getInfo
```
ArangoCollection.getInfo() : CollectionEntity
```
Returns information about the collection.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("potatos");
CollectionEntity info = collection.getInfo();
```
## ArangoCollection.getProperties
```
ArangoCollection.getProperties() : CollectionPropertiesEntity
```
Reads the properties of the specified collection.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("potatos");
CollectionPropertiesEntity properties = collection.getProperties();
```
## ArangoCollection.getRevision
```
ArangoCollection.getRevision() : CollectionRevisionEntity
```
Retrieve the collections revision.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("potatos");
CollectionRevisionEntity revision = collection.getRevision();
```
## ArangoCollection.getIndexes
```
ArangoCollection.getIndexes() : Collection<IndexEntity>
```
Fetches a list of all indexes on this collection.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("potatos");
Collection<IndexEntity> indexes = collection.getIndexes();
```

View File

@ -0,0 +1,79 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Cursor API
_ArangoCursor_ instances provide an abstraction over the HTTP API's limitations. Unless a method explicitly exhausts the cursor, the driver will only fetch as many batches from the server as necessary. Like the server-side cursors, _ArangoCursor_ instances are incrementally depleted as they are read from.
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCursor<Integer> cursor = db.query("FOR x IN 1..5 RETURN x", null, null, Integer.class);
// query result list: [1, 2, 3, 4, 5]
Integer value = cursor.next();
assertThat(value, is(1));
// remaining result list: [2, 3, 4, 5]
```
## ArangoCursor.hasNext
```
ArangoCursor.hasNext() : boolean
```
Returns _true_ if the cursor has more elements in its current batch of results or the cursor on the server has more batches.
## ArangoCursor.next
```
ArangoCursor.next() : T
```
Returns the next element of the query result. If the current element is the last element of the batch and the cursor on the server provides more batches, the next batch is fetched from the server.
## ArangoCursor.iterator
```
ArangoCursor.iterator() : Iterator<T>
```
Returns an iterator over elements of the query result.
## ArangoCursor.asListRemaining
```
ArangoCursor.asListRemaining() : List<T>
```
Returns the remaining results as a _List_.
## ArangoCursor.getCount
```
ArangoCursor.getCount() : Integer
```
Returns the total number of result documents available (only available if the query was executed with the _count_ attribute set)
## ArangoCursor.getStats
```
ArangoCursor.getStats() : Stats
```
Returns extra information about the query result. For data-modification queries, the stats will contain the number of modified documents and the number of documents that could not be modified due to an error (if ignoreErrors query option is specified);
## ArangoCursor.getWarnings
```
ArangoCursor.getWarnings() : Collection<Warning>
```
Returns warnings which the query could have been produced.
## ArangoCursor.isCached
```
ArangoCursor.isCached() : boolean
```
Iindicating whether the query result was served from the query cache or not.

View File

@ -0,0 +1,95 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Managing AQL user functions
These functions implement the
[HTTP API for managing AQL user functions](../../../..//HTTP/AqlUserFunctions/index.html).
## ArangoDatabase.getAqlFunctions
```
ArangoDatabase.getAqlFunctions(AqlFunctionGetOptions options) : Collection<AqlFunctionEntity>
```
**Arguments**
- **options**: `AqlFunctionGetOptions`
- **namespace**: `String`
Returns all registered AQL user functions from namespace namespace
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
Collection<AqlFunctionEntity> functions = db.getAqlFunctions(new AqlFunctionGetOptions().namespace("myfuncs"));
// functions is a list of function descriptions
```
## ArangoDatabase.createAqlFunction
```
ArangoDatabase.createAqlFunction(String name, String code, AqlFunctionCreateOptions options) : void
```
**Arguments**
- **name**: `String`
A valid AQL function name, e.g.: `"myfuncs::accounting::calculate_vat"`
- **code**: `String`
A String evaluating to a JavaScript function
- **options**: `AqlFunctionCreateOptions`
- **isDeterministic**: `Boolean`
An optional boolean value to indicate that the function results are fully deterministic (function return value solely depends on the input value and return value is the same for repeated calls with same input)
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
db.createAqlFunction("ACME::ACCOUNTING::CALCULATE_VAT",
"function (price) { return 0.19; }",
new AqlFunctionCreateOptions());
// Use the new function in an AQL query
String query = "FOR product IN products"
+ "RETURN MERGE("
+ "{vat: ACME::ACCOUNTING::CALCULATE_VAT(product.price)}, product)";
ArangoCursor<Double> cursor = db.query(query, null, new AqlQueryOptions(), Double.class);
// cursor is a cursor for the query result
```
## ArangoDatabase.deleteAqlFunction
```
ArangoDatabase.deleteAqlFunction(String name, AqlFunctionDeleteOptions options): Integer
```
Deletes the AQL user function with the given name from the database.
**Arguments**
- **name**: `String`
The name of the user function to delete
- **options**: `AqlFunctionDeleteOptions`
- **group**: `Boolean`
If set to true, then the function name provided in name is treated as a namespace prefix, and all functions in the specified namespace will be deleted. If set to false, the function name provided in name must be fully qualified, including any namespaces.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
db.deleteAqlFunction("ACME::ACCOUNTING::CALCULATE_VAT", new AqlFunctionDeleteOptions());
// the function no longer exists
```

View File

@ -0,0 +1,43 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Accessing collections
These functions implement the
[HTTP API for accessing collections](../../../..//HTTP/Collection/Getting.html).
## ArangoDatabase.collection
```
ArangoDatabase.collection(String name) : ArangoCollection
```
Returns a _ArangoCollection_ instance for the given collection name.
**Arguments**
- **name**: `String`
Name of the collection
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCollection collection = db.collection("myCollection");
```
## ArangoDatabase.getCollections
```
ArangoDatabase.getCollections() : Collection<CollectionEntity>
```
Fetches all collections from the database and returns an list of collection descriptions.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
Collection<CollectionEntity> infos = db.getCollections();
```

View File

@ -0,0 +1,107 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulation databases
These functions implement the
[HTTP API for manipulating databases](../../../..//HTTP/Database/index.html).
## ArangoDB.createDatabase
```
ArangoDB.createDatabase(String name) : Boolean
```
Creates a new database with the given name.
**Arguments**
- **name**: `String`
Name of the database to create
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
arango.createDatabase("myDB");
```
## ArangoDatabase.create()
```
ArangoDatabase.create() : Boolean
```
Creates the database.
Alternative for [ArangoDB.createDatabase](#arangodbcreatedatabase).
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
db.create();
```
## ArangoDatabase.exists()
```
ArangoDatabase.exists() : boolean
```
Checks whether the database exists
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
boolean exists = db.exists();
```
## ArangoDatabase.getInfo
```
ArangoDatabase.getInfo() : DatabaseEntity
```
Retrieves information about the current database
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
DatabaseEntity info = db.getInfo();
```
## ArangoDB.getDatabases
```
ArangoDB.getDatabases() : Collection<String>
```
Retrieves a list of all existing databases
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
Collection<String> names = arango.getDatabases();
```
## ArangoDatabase.drop
```
ArangoDatabase.drop() : Boolean
```
Deletes the database from the server.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
db.drop();
```

View File

@ -0,0 +1,27 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Accessing graphs
These functions implement the
[HTTP API for accessing general graphs](../../../..//HTTP/Gharial/index.html).
## ArangoDatabase.graph
```
ArangoDatabase.graph(String name) : ArangoGraph
```
Returns a _ArangoGraph_ instance for the given graph name.
**Arguments**
- **name**: `String`
Name of the graph
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("myGraph");
```

View File

@ -0,0 +1,30 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Arbitrary HTTP routes
## ArangoDatabase.route
```
ArangoDatabase.route(String... path) : ArangoRoute
```
Returns a new _ArangoRoute_ instance for the given path (relative to the database) that can be used to perform arbitrary requests.
**Arguments**
- **path**: `String...`
The database-relative URL of the route
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute myFoxxService = db.route("my-foxx-service");
VPackSlice body = arango.util().serialize("{'username': 'admin', 'password': 'hunter2'");
Response response = myFoxxService.route("users").withBody(body).post();
// response.getBody() is the result of
// POST /_db/myDB/my-foxx-service/users
// with VelocyPack request body '{"username": "admin", "password": "hunter2"}'
```

View File

@ -0,0 +1,108 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Queries
This function implements the
[HTTP API for single roundtrip AQL queries](../../../..//HTTP/AqlQueryCursor/QueryResults.html).
## ArangoDatabase.query
```
ArangoDatabase.query(String query, Map<String, Object> bindVars, AqlQueryOptions options, Class<T> type) : ArangoCursor<T>
```
Performs a database query using the given _query_ and _bindVars_, then returns a new _ArangoCursor_ instance for the result list.
**Arguments**
- **query**: `String`
An AQL query string
- **bindVars**: `Map<String, Object>`
key/value pairs defining the variables to bind the query to
- **options**: `AqlQueryOptions`
- **count**: `Boolean`
Indicates whether the number of documents in the result set should be returned in the "count" attribute of the result. Calculating the "count" attribute might have a performance impact for some queries in the future so this option is turned off by default, and "count" is only returned when requested.
- **ttl**: `Integer`
The time-to-live for the cursor (in seconds). The cursor will be removed on the server automatically after the specified amount of time. This is useful to ensure garbage collection of cursors that are not fully fetched by clients. If not set, a server-defined value will be used.
- **batchSize**: `Integer`
Maximum number of result documents to be transferred from the server to the client in one roundtrip. If this attribute is not set, a server-controlled default value will be used. A batchSize value of 0 is disallowed.
- **memoryLimit**: `Long`
The maximum number of memory (measured in bytes) that the query is allowed to use. If set, then the query will fail with error "resource limit exceeded" in case it allocates too much memory. A value of 0 indicates that there is no memory limit.
- **cache**: `Boolean`
Flag to determine whether the AQL query cache shall be used. If set to false, then any query cache lookup will be skipped for the query. If set to true, it will lead to the query cache being checked for the query if the query cache mode is either on or demand.
- **failOnWarning**: `Boolean`
When set to true, the query will throw an exception and abort instead of producing a warning. This option should be used during development to catch potential issues early. When the attribute is set to false, warnings will not be propagated to exceptions and will be returned with the query result. There is also a server configuration option --query.fail-on-warning for setting the default value for failOnWarning so it does not need to be set on a per-query level.
- **profile**: `Boolean`
If set to true, then the additional query profiling information will be returned in the sub-attribute profile of the extra return attribute if the query result is not served from the query cache.
- **maxTransactionSize**: `Long`
Transaction size limit in bytes. Honored by the RocksDB storage engine only.
- **maxWarningCount**: `Long`
Limits the maximum number of warnings a query will return. The number of warnings a query will return is limited to 10 by default, but that number can be increased or decreased by setting this attribute.
- **intermediateCommitCount**: `Long`
Maximum number of operations after which an intermediate commit is performed automatically. Honored by the RocksDB storage engine only.
- **intermediateCommitSize**: `Long`
Maximum total size of operations after which an intermediate commit is performed automatically. Honored by the RocksDB storage engine only.
- **satelliteSyncWait**: `Double`
This enterprise parameter allows to configure how long a DBServer will have time to bring the satellite collections involved in the query into sync. The default value is 60.0 (seconds). When the max time has been reached the query will be stopped.
- **skipInaccessibleCollections**
AQL queries (especially graph traversals) will treat collection to which a user has no access rights as if these collections were empty. Instead of returning a forbidden access error, your queries will execute normally. This is intended to help with certain use-cases: A graph contains several collections and different users execute AQL queries on that graph. You can now naturally limit the accessible results by changing the access rights of users on collections. This feature is only available in the Enterprise Edition.
- **fullCount**: `Boolean`
If set to true and the query contains a LIMIT clause, then the result will have an extra attribute with the sub-attributes stats and fullCount, { ... , "extra": { "stats": { "fullCount": 123 } } }. The fullCount attribute will contain the number of documents in the result before the last LIMIT in the query was applied. It can be used to count the number of documents that match certain filter criteria, but only return a subset of them, in one go. It is thus similar to MySQL's SQL_CALC_FOUND_ROWS hint. Note that setting the option will disable a few LIMIT optimizations and may lead to more documents being processed, and thus make queries run longer. Note that the fullCount attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query.
- **maxPlans**: `Integer`
Limits the maximum number of plans that are created by the AQL query optimizer.
- **rules**: `Collection<String>`
A list of to-be-included or to-be-excluded optimizer rules can be put into this attribute, telling the optimizer to include or exclude specific rules. To disable a rule, prefix its name with a -, to enable a rule, prefix it with a +. There is also a pseudo-rule all, which will match all optimizer rules.
- **stream**: `Boolean`
Specify true and the query will be executed in a streaming fashion. The query result is not stored on the server, but calculated on the fly. Beware: long-running queries will need to hold the collection locks for as long as the query cursor exists. When set to false a query will be executed right away in its entirety. In that case query results are either returned right away (if the resultset is small enough), or stored on the arangod instance and accessible via the cursor API (with respect to the ttl). It is advisable to only use this option on short-running queries or without exclusive locks (write-locks on MMFiles). Please note that the query options cache, count and fullCount will not work on streaming queries. Additionally query statistics, warnings and profiling data will only be available after the query is finished. The default value is false.
- **type**: `Class<T>`
The type of the result (POJO class, `VPackSlice`, `String` for Json, or `Collection`/`List`/`Map`)
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoCursor<BaseDocument> cursor = db.query("FOR i IN @@collection RETURN i"
new MapBuilder().put("@collection", "myCollection").get(),
new AqlQueryOptions(),
BaseDocument.class);
```

View File

@ -0,0 +1,23 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Database API
## ArangoDB.db
```
ArangoDB.db(String name) : ArangoDatabase
```
Returns a _ArangoDatabase_ instance for the given database name.
**Arguments**
- **name**: `String`
Name of the database
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
```

View File

@ -0,0 +1,39 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Transactions
This function implements the
[HTTP API for transactions](../../../..//HTTP/Transaction/index.html).
## ArangoDatabase.transaction
```
ArangoDatabase.transaction(String action, Class<T> type, TransactionOptions options) : T
```
Performs a server-side transaction and returns its return value.
**Arguments**
- **action**: `String`
A String evaluating to a JavaScript function to be executed on the server.
- **type**: `Class`
The type of the result (POJO class, `VPackSlice` or `String` for Json)
- **options**: `TransactionOptions`
Additional transaction options
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
String action = "function (params) {"
+ "const db = require('@arangodb').db;"
+ "return db._query('FOR i IN test RETURN i._key').toArray();"
+ "}";
String[] keys = arango.db().transaction(action, String[].class, new TransactionOptions());
```

View File

@ -0,0 +1,134 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating the edge collection
## ArangoGraph.edgeCollection
```
ArangoGraph.edgeCollection(String name) : ArangoEdgeColleciton
```
Returns a _ArangoEdgeCollection_ instance for the given edge collection name.
**Arguments**
- **name**: `String`
Name of the edge collection
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoEdgeCollection collection = graph.edgeCollection("some-edge-collection");
```
## ArangoGraph.getEdgeDefinitions
```
ArangoGraph.getEdgeDefinitions() : Collection<String>
```
Fetches all edge collections from the graph and returns a list of collection names.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
Collection<String> collections = graph.getEdgeDefinitions();
```
## ArangoGraph.addEdgeDefinition
```
ArangoGraph.addEdgeDefinition(EdgeDefinition definition) : GraphEntity
```
Adds the given edge definition to the graph.
**Arguments**
- **definition**: `EdgeDefinition`
The edge definition
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
EdgeDefinition edgeDefinition = new EdgeDefinition()
.collection("edges")
.from("start-vertices")
.to("end-vertices");
graph.addEdgeDefinition(edgeDefinition);
// the edge definition has been added to the graph
```
## ArangoGraph.replaceEdgeDefinition
```
ArangoGraph.replaceEdgeDefinition(EdgeDefinition definition) : GraphEntity
```
Change one specific edge definition. This will modify all occurrences of this definition in all graphs known to your database.
**Arguments**
- **definition**: `EdgeDefinition`
The edge definition
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
EdgeDefinition edgeDefinition = new EdgeDefinition()
.collection("edges")
.from("start-vertices")
.to("end-vertices");
graph.replaceEdgeDefinition(edgeDefinition);
// the edge definition has been modified
```
## ArangoGraph.removeEdgeDefinition
```
ArangoGraph.removeEdgeDefinition(String definitionName) : GraphEntity
```
Remove one edge definition from the graph. This will only remove the edge collection, the vertex collections remain untouched and can still be used in your queries.
**Arguments**
- **definitionName**: `String`
The name of the edge collection used in the definition
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
EdgeDefinition edgeDefinition = new EdgeDefinition()
.collection("edges")
.from("start-vertices")
.to("end-vertices");
graph.addEdgeDefinition(edgeDefinition);
// the edge definition has been added to the graph
graph.removeEdgeDefinition("edges");
// the edge definition has been removed
```

View File

@ -0,0 +1,186 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating edges
## ArangoEdgeCollection.getEdge
```
ArangoEdgeCollection.getEdge(String key, Class<T> type, DocumentReadOptions options) : T
```
Retrieves the edge document with the given <code>key</code> from the collection.
**Arguments**
- **key**: `String`
The key of the edge
- **type**: `Class<T>`
The type of the edge-document (POJO class, `VPackSlice` or `String` for Json)
- **options**: `DocumentReadOptions`
- **ifNoneMatch**: `String`
Document revision must not contain If-None-Match
- **ifMatch**: `String`
Document revision must contain If-Match
- **catchException**: `Boolean`
Whether or not catch possible thrown exceptions
## ArangoEdgeCollection.insertEdge
```
ArangoEdgeCollection.insertEdge(T value, EdgeCreateOptions options) : EdgeEntity
```
Creates a new edge in the collection.
**Arguments**
- **value**: `T`
A representation of a single edge (POJO, `VPackSlice` or `String` for Json)
- **options**: `EdgeCreateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoEdgeCollection collection = graph.edgeCollection("some-edge-collection");
BaseEdgeDocument document = new BaseEdgeDocument("some-from-key", "some-to-key");
document.addAttribute("some", "data");
collection.insertEdge(document, new EdgeCreateOptions());
```
## ArangoEdgeCollection.replaceEdge
```
ArangoEdgeCollection.replaceEdge(String key, T value, EdgeReplaceOptions options) : EdgeUpdateEntity
```
Replaces the edge with key with the one in the body, provided there is such a edge and no precondition is violated.
**Arguments**
- **key**: `String`
The key of the edge
- **value**: `T`
A representation of a single edge (POJO, `VPackSlice` or `String` for Json)
- **options**: `EdgeReplaceOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ifMatch**: `String`
Replace a document based on target revision
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoEdgeCollection collection = graph.edgeCollection("some-edge-collection");
BaseEdgeDocument document = new BaseEdgeDocument("some-from-key", "some-to-key");
collection.replaceEdge("some-key", document, new EdgeReplaceOptions());
```
## ArangoEdgeCollection.updateEdge
```
ArangoEdgeCollection.updateEdge(String key, T value, EdgeUpdateOptions options) : EdgeUpdateEntity
```
Updates the edge with key with the one in the body, provided there is such a edge and no precondition is violated.
**Arguments**
- **key**: `String`
The key of the edge
- **value**: `T`
A representation of a single edge (POJO, `VPackSlice` or `String` for Json)
- **options**: `EdgeUpdateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ifMatch**: `String`
Update a document based on target revision
- **keepNull**: `Boolean`
If the intention is to delete existing attributes with the patch command, the URL query parameter keepNull can be used with a value of false. This will modify the behavior of the patch command to remove any attributes from the existing document that are contained in the patch document with an attribute value of null.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoEdgeCollection collection = graph.edgeCollection("some-edge-collection");
BaseEdgeDocument document = new BaseEdgeDocument("some-from-key", "some-to-key");
collection.updateEdge("some-key", document, new EdgeUpdateOptions());
```
## ArangoEdgeCollection.deleteEdge
```
ArangoEdgeCollection.deleteEdge(String key, EdgeDeleteOptions options) : void
```
Deletes the edge with the given _key_ from the collection.
**Arguments**
- **key**: `String`
The key of the edge
- **options** : `EdgeDeleteOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ifMatch**: `String`
Remove a document based on target revision
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoEdgeCollection collection = graph.edgeCollection("some-edge-collection");
collection.deleteEdge("some-key", new EdgeDeleteOptions());
```

View File

@ -0,0 +1,167 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Graph API
These functions implement the
[HTTP API for manipulating graphs](../../../..//HTTP/Gharial/index.html).
## ArangoDatabase.createGraph
```
## ArangoDatabase.createGraph(String name, Collection<EdgeDefinition> edgeDefinitions, GraphCreateOptions options) : GraphEntity
```
Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition of its edges.
**Arguments**
- **name**: `String`
Name of the graph
- **edgeDefinitions**: `Collection<EdgeDefinition>`
An array of definitions for the edge
- **options**: `GraphCreateOptions`
- **orphanCollections**: `String...`
Additional vertex collections
- **isSmart**: `Boolean`
Define if the created graph should be smart. This only has effect in Enterprise version.
- **replicationFactor**: `Integer`
(The default is 1): in a cluster, 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.
- **numberOfShards**: `Integer`
The number of shards that is used for every collection within this graph. Cannot be modified later.
- **smartGraphAttribute**: `String`
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.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
EdgeDefinition edgeDefinition = new EdgeDefinition()
.collection("edges")
.from("start-vertices")
.to("end-vertices");
GraphEntity graph = db.createGraph("some-graph", Arrays.asList(edgeDefinition), new GraphCreateOptions());
// graph now exists
```
## ArangoGraph.create
```
## ArangoGraph.create(Collection<EdgeDefinition> edgeDefinitions, GraphCreateOptions options) : GraphEntity
```
Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition of its edges.
Alternative for [ArangoDatabase.createGraph](#arangodatabasecreategraph).
**Arguments**
- **edgeDefinitions**: `Collection<EdgeDefinition>`
An array of definitions for the edge
- **options**: `GraphCreateOptions`
- **orphanCollections**: `String...`
Additional vertex collections
- **isSmart**: `Boolean`
Define if the created graph should be smart. This only has effect in Enterprise version.
- **replicationFactor**: `Integer`
(The default is 1): in a cluster, 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.
- **numberOfShards**: `Integer`
The number of shards that is used for every collection within this graph. Cannot be modified later.
- **smartGraphAttribute**: `String`
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.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
EdgeDefinition edgeDefinition = new EdgeDefinition()
.collection("edges")
.from("start-vertices")
.to("end-vertices");
graph.create(Arrays.asList(edgeDefinition), new GraphCreateOptions());
// graph now exists
```
## ArangoGraph.exists
```
ArangoGraph.exists() : boolean
```
Checks whether the graph exists
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
boolean exists = graph.exists();
```
## ArangoGraph.getInfo
```
ArangoGraph.getInfo() : GraphEntity
```
Retrieves general information about the graph.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
GraphEntity info = graph.getInfo();
```
## ArangoGraph.drop
```
ArangoGraph.drop() : void
```
Deletes the graph from the database.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
graph.drop();
// the graph "some-graph" no longer exists
```

View File

@ -0,0 +1,68 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating the vertex collection
## ArangoGraph.vertexCollection
```
ArangoGraph.vertexCollection(String name) : ArangoVertexCollection
```
Returns a _ArangoVertexCollection_ instance for the given vertex collection name.
**Arguments**
- **name**: `String`
Name of the vertex collection
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoVertexCollection collection = graph.vertexCollection("some-vertex-collection");
```
## ArangoGraph.getVertexCollections
```
ArangoGraph.getVertexCollections() : Collection<String>
```
Fetches all vertex collections from the graph and returns a list of collection names.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
Collection<String> collections = graph.getVertexCollections();
```
## ArangoGraph.addVertexCollection
```
ArangoGraph.addVertexCollection(String name) : GraphEntity
```
Adds a vertex collection to the set of collections of the graph. If the collection does not exist, it will be created.
**Arguments**
- **name**: `String`
Name of the vertex collection
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
graph.addVertexCollection("some-other-collection");
```

View File

@ -0,0 +1,186 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Manipulating vertices
## ArangoVertexCollection.getVertex
```
ArangoVertexCollection.getVertex(String key, Class<T> type, DocumentReadOptions options) : T
```
Retrieves the vertex document with the given <code>key</code> from the collection.
**Arguments**
- **key**: `String`
The key of the vertex
- **type**: `Class<T>`
The type of the vertex-document (POJO class, `VPackSlice` or `String` for Json)
- **options**: `DocumentReadOptions`
- **ifNoneMatch**: `String`
Document revision must not contain If-None-Match
- **ifMatch**: `String`
Document revision must contain If-Match
- **catchException**: `Boolean`
Whether or not catch possible thrown exceptions
## ArangoVertexCollection.insertVertex
```
ArangoVertexCollection.insertVertex(T value, VertexCreateOptions options) : VertexEntity
```
Creates a new vertex in the collection.
**Arguments**
- **value**: `T`
A representation of a single vertex (POJO, `VPackSlice` or `String` for Json)
- **options**: `VertexCreateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoVertexCollection collection = graph.vertexCollection("some-vertex-collection");
BaseDocument document = new BaseDocument();
document.addAttribute("some", "data");
collection.insertVertex(document, new VertexCreateOptions());
```
## ArangoVertexCollection.replaceVertex
```
ArangoVertexCollection.replaceVertex(String key, T value, VertexReplaceOptions options) : VertexUpdateEntity
```
Replaces the vertex with key with the one in the body, provided there is such a vertex and no precondition is violated.
**Arguments**
- **key**: `String`
The key of the vertex
- **value**: `T`
A representation of a single vertex (POJO, `VPackSlice` or `String` for Json)
- **options**: `VertexReplaceOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ifMatch**: `String`
Replace a document based on target revision
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoVertexCollection collection = graph.vertexCollection("some-vertex-collection");
BaseDocument document = new BaseDocument();
collection.replaceVertex("some-key", document, new VertexReplaceOptions());
```
## ArangoVertexCollection.updateVertex
```
ArangoVertexCollection.updateVertex(String key, T value, VertexUpdateOptions options) : VertexUpdateEntity
```
Updates the vertex with key with the one in the body, provided there is such a vertex and no precondition is violated.
**Arguments**
- **key**: `String`
The key of the vertex
- **value**: `T`
A representation of a single vertex (POJO, `VPackSlice` or `String` for Json)
- **options**: `VertexUpdateOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ifMatch**: `String`
Update a document based on target revision
- **keepNull**: `Boolean`
If the intention is to delete existing attributes with the patch command, the URL query parameter keepNull can be used with a value of false. This will modify the behavior of the patch command to remove any attributes from the existing document that are contained in the patch document with an attribute value of null.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoVertexCollection collection = graph.vertexCollection("some-vertex-collection");
BaseDocument document = new BaseDocument();
collection.updateVertex("some-key", document, new VertexUpdateOptions());
```
## ArangoVertexCollection.deleteVertex
```
ArangoVertexCollection.deleteVertex(String key, VertexDeleteOptions options) : void
```
Deletes the vertex with the given _key_ from the collection.
**Arguments**
- **key**: `String`
The key of the vertex
- **options** : `VertexDeleteOptions`
- **waitForSync**: `Boolean`
Wait until document has been synced to disk.
- **ifMatch**: `String`
Remove a document based on target revision
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoGraph graph = db.graph("some-graph");
ArangoVertexCollection collection = graph.vertexCollection("some-vertex-collection");
collection.deleteVertex("some-key", new VertexDeleteOptions());
```

View File

@ -2,6 +2,27 @@
# ArangoDB Java Driver - Reference
- [Driver Setup](Setup.md)
- [Database](Database/README.md)
- [Database Manipulation](Database/DatabaseManipulation.md)
- [Collection Access](Database/CollectionAccess.md)
- [Queries](Database/Queries.md)
- [AQL User Functions](Database/AqlUserFunctions.md)
- [Transactions](Database/Transactions.md)
- [Graph Access](Database/GraphAccess.md)
- [HTTP Routes](Database/HttpRoutes.md)
- [Collection](Collection/README.md)
- [Collection Manipulation](Collection/CollectionManipulation.md)
- [Document Manipulation](Collection/DocumentManipulation.md)
- [Indexes](Collection/Indexes.md)
- [Bulk Import](Collection/BulkImport.md)
- [Cursor](Cursor.md)
- [Graph](Graph/README.md)
- [Vertex Collection](Graph/VertexCollection.md)
- [Edge Collection](Graph/EdgeCollection.md)
- [Vertices Manipulation](Graph/Vertices.md)
- [Edges Manipulation](Graph/Edges.md)
- [Route](Route.md)
- [Serialization](Serialization.md)
- [Manipulating databases/collections](DatabaseCollection.md)
- [Basic document operations](Document.md)
- [Multi document operations](MultiDocument.md)
@ -9,4 +30,3 @@
- [Graphs](Graph.md)
- [Foxx](Foxx.md)
- [User Management](UserManagement.md)
- [Serialization](Serialization.md)

View File

@ -0,0 +1,290 @@
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
# Route API
_ArangoRoute_ instances provide access for arbitrary HTTP requests. This allows easy access to Foxx services and other HTTP APIs not covered by the driver itself.
## ArangoRoute.route
```
ArangoRoute.route(String... path) : ArangoRoute
```
Returns a new _ArangoRoute_ instance for the given path (relative to the current route) that can be used to perform arbitrary requests.
**Arguments**
- **path**: `String...`
The relative URL of the route
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
ArangoRoute users = route.route("users");
// equivalent to db.route("my-foxx-service/users")
// or db.route("my-foxx-service", "users")
```
## ArangoRoute.withHeader
```
ArangoRoute.withHeader(String key, Object value) : ArangoRoute
```
Header that should be sent with each request to the route.
**Arguments**
- **key**: `String`
Header key
- **value**: `Object`
Header value (the _toString()_ method will be called for the value}
## ArangoRoute.withQueryParam
```
ArangoRoute.withQueryParam(String key, Object value) : ArangoRoute
```
Query parameter that should be sent with each request to the route.
**Arguments**
- **key**: `String`
Query parameter key
- **value**: `Object`
Query parameter value (the _toString()_ method will be called for the value}
## ArangoRoute.withBody
```
ArangoRoute.withBody(Object body) : ArangoRoute
```
The response body. The body will be serialized to _VPackSlice_.
**Arguments**
- **body**: `Object`
The request body
## ArangoRoute.delete
```
ArangoRoute.delete() : Response
```
Performs a DELETE request to the given URL and returns the server response.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
ArangoRoute route = route.delete()
// response.getBody() is the response body of calling
// DELETE _db/_system/my-foxx-service
// -- or --
ArangoRoute route = route.route("users/admin").delete()
// response.getBody() is the response body of calling
// DELETE _db/_system/my-foxx-service/users/admin
// -- or --
ArangoRoute route = route.route("users/admin").withQueryParam("permanent", true).delete()
// response.getBody() is the response body of calling
// DELETE _db/_system/my-foxx-service/users/admin?permanent=true
```
## ArangoRoute.get
```
ArangoRoute.get() : Response
```
Performs a GET request to the given URL and returns the server response.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
Response response = route.get();
// response.getBody() is the response body of calling
// GET _db/_system/my-foxx-service
// -- or --
Response response = route.route("users").get();
// response.getBody() is the response body of calling
// GET _db/_system/my-foxx-service/users
// -- or --
Response response = route.route("users").withQueryParam("group", "admin").get();
// response.getBody() is the response body of calling
// GET _db/_system/my-foxx-service/users?group=admin
```
## ArangoRoute.head
```
ArangoRoute.head() : Response
```
Performs a HEAD request to the given URL and returns the server response.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
ArangoRoute route = route.head();
// response is the response object for
// HEAD _db/_system/my-foxx-service
```
## ArangoRoute.patch
```
ArangoRoute.patch() : Response
```
Performs a PATCH request to the given URL and returns the server response.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
ArangoRoute route = route.patch();
// response.getBody() is the response body of calling
// PATCH _db/_system/my-foxx-service
// -- or --
ArangoRoute route = route.route("users/admin").patch();
// response.getBody() is the response body of calling
// PATCH _db/_system/my-foxx-service/users
// -- or --
VPackSlice body = arango.util().serialize("{ password: 'hunter2' }");
ArangoRoute route = route.route("users/admin").withBody(body).patch();
// response.getBody() is the response body of calling
// PATCH _db/_system/my-foxx-service/users/admin
// with JSON request body {"password": "hunter2"}
// -- or --
VPackSlice body = arango.util().serialize("{ password: 'hunter2' }");
ArangoRoute route = route.route("users/admin").withBody(body).withQueryParam("admin", true).patch();
// response.getBody() is the response body of calling
// PATCH _db/_system/my-foxx-service/users/admin?admin=true
// with JSON request body {"password": "hunter2"}
```
## ArangoRoute.post
```
ArangoRoute.post() : Response
```
Performs a POST request to the given URL and returns the server response.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
ArangoRoute route = route.post()
// response.getBody() is the response body of calling
// POST _db/_system/my-foxx-service
// -- or --
ArangoRoute route = route.route("users").post()
// response.getBody() is the response body of calling
// POST _db/_system/my-foxx-service/users
// -- or --
VPackSlice body = arango.util().serialize("{ password: 'hunter2' }");
ArangoRoute route = route.route("users").withBody(body).post();
// response.getBody() is the response body of calling
// POST _db/_system/my-foxx-service/users
// with JSON request body {"username": "admin", "password": "hunter2"}
// -- or --
VPackSlice body = arango.util().serialize("{ password: 'hunter2' }");
ArangoRoute route = route.route("users").withBody(body).withQueryParam("admin", true).post();
// response.getBody() is the response body of calling
// POST _db/_system/my-foxx-service/users?admin=true
// with JSON request body {"username": "admin", "password": "hunter2"}
```
## ArangoRoute.put
```
ArangoRoute.put() : Response
```
Performs a PUT request to the given URL and returns the server response.
**Examples**
```Java
ArangoDB arango = new ArangoDB.Builder().build();
ArangoDatabase db = arango.db("myDB");
ArangoRoute route = db.route("my-foxx-service");
ArangoRoute route = route.put();
// response.getBody() is the response body of calling
// PUT _db/_system/my-foxx-service
// -- or --
ArangoRoute route = route.route("users/admin").put();
// response.getBody() is the response body of calling
// PUT _db/_system/my-foxx-service/users
// -- or --
VPackSlice body = arango.util().serialize("{ password: 'hunter2' }");
ArangoRoute route = route.route("users/admin").withBody(body).put();
// response.getBody() is the response body of calling
// PUT _db/_system/my-foxx-service/users/admin
// with JSON request body {"username": "admin", "password": "hunter2"}
// -- or --
VPackSlice body = arango.util().serialize("{ password: 'hunter2' }");
ArangoRoute route = route.route("users/admin").withBody(body).withQueryParam("admin", true).put();
// response.getBody() is the response body of calling
// PUT _db/_system/my-foxx-service/users/admin?admin=true
// with JSON request body {"username": "admin", "password": "hunter2"}
```

View File

@ -7,22 +7,27 @@ Since version `4.1.11` you can extend the VelocyPack serialization by registerin
### Java 8 types
GitHub: https://github.com/arangodb/java-velocypack-module-jdk8
Added support for:
* java.time.Instant
* java.time.LocalDate
* java.time.LocalDateTime
* java.util.Optional;
* java.util.OptionalDouble;
* java.util.OptionalInt;
* java.util.OptionalLong;
- `java.time.Instant`
- `java.time.LocalDate`
- `java.time.LocalDateTime`
- `java.time.ZonedDateTime`
- `java.time.OffsetDateTime`
- `java.time.ZoneId`
- `java.util.Optional`
- `java.util.OptionalDouble`
- `java.util.OptionalInt`
- `java.util.OptionalLong`
```XML
<dependencies>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>velocypack-module-jdk8</artifactId>
<version>1.0.2</version>
<version>1.1.0</version>
</dependency>
</dependencies>
```
@ -33,18 +38,22 @@ ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJdk8Module())
### Scala types
GitHub: https://github.com/arangodb/java-velocypack-module-scala
Added support for:
* scala.Option
* scala.collection.immutable.List
* scala.collection.immutable.Map
- `scala.Option`
- `scala.collection.immutable.List`
- `scala.collection.immutable.Map`
- `scala.math.BigInt`
- `scala.math.BigDecimal`
```XML
<dependencies>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>velocypack-module-scala</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
</dependencies>
```
@ -55,19 +64,21 @@ val arangoDB: ArangoDB = new ArangoDB.Builder().registerModule(new VPackScalaMod
### Joda-Time
GitHub: https://github.com/arangodb/java-velocypack-module-joda
Added support for:
* org.joda.time.DateTime;
* org.joda.time.Instant;
* org.joda.time.LocalDate;
* org.joda.time.LocalDateTime;
- `org.joda.time.DateTime`
- `org.joda.time.Instant`
- `org.joda.time.LocalDate`
- `org.joda.time.LocalDateTime`
```XML
<dependencies>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>velocypack-module-joda</artifactId>
<version>1.0.0</version>
<version>1.1.1</version>
</dependency>
</dependencies>
```
@ -78,8 +89,7 @@ ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule())
## Use of jackson as an alternative serializer
Since version 4.5.2, the driver supports alternative serializer to de-/serialize documents, edges and query results. One implementation is [VelocyJack](https://github.com/arangodb/jackson-dataformat-velocypack#usage-within-arangodb-java-driver) which is based on [Jackson](https://github.com/FasterXML/jackson) working with [jackson-dataformat-velocypack](https://github.com/arangodb/jackson-dataformat-velocypack).
Since version 4.5.2, the driver supports alternative serializer to de-/serialize documents, edges and query results. One implementation is [VelocyJack](https://github.com/arangodb/jackson-dataformat-velocypack#within-arangodb-java-driver) which is based on [Jackson](https://github.com/FasterXML/jackson) working with [jackson-dataformat-velocypack](https://github.com/arangodb/jackson-dataformat-velocypack).
**Note**: Any registered custom [serializer/deserializer or module](#custom-serialization) will be ignored.

View File

@ -5,15 +5,35 @@
* [Java Driver](Java/README.md)
* [Getting Started](Java/GettingStarted/README.md)
* [Reference](Java/Reference/README.md)
* [Driver Setup](Java/Reference/Setup.md)
* [Manipulating databases/collections](Java/Reference/DatabaseCollection.md)
* [Basic document operations](Java/Reference/Document.md)
* [Multi document operations](Java/Reference/MultiDocument.md)
* [AQL](Java/Reference/AQL.md)
* [Graphs](Java/Reference/Graph.md)
* [Foxx](Java/Reference/Foxx.md)
* [User Management](Java/Reference/UserManagement.md)
* [Serialization](Java/Reference/Serialization.md)
* [Driver Setup](Java/Reference/Setup.md)
* [Database](Java/Reference/Database/README.md)
* [Database Manipulation](Java/Reference/Database/DatabaseManipulation.md)
* [Collection Access](Java/Reference/Database/CollectionAccess.md)
* [Queries](Java/Reference/Database/Queries.md)
* [AQL User Functions](Java/Reference/Database/AqlUserFunctions.md)
* [Transactions](Java/Reference/Database/Transactions.md)
* [Graph Access](Java/Reference/Database/GraphAccess.md)
* [HTTP Routes](Java/Reference/Database/HttpRoutes.md)
* [Collection](Java/Reference/Collection/README.md)
* [Collection Manipulation](Java/Reference/Collection/CollectionManipulation.md)
* [Document Manipulation](Java/Reference/Collection/DocumentManipulation.md)
* [Indexes](Java/Reference/Collection/Indexes.md)
* [Bulk Import](Java/Reference/Collection/BulkImport.md)
* [Cursor](Java/Reference/Cursor.md)
* [Graph](Java/Reference/Graph/README.md)
* [Vertex Collection](Java/Reference/Graph/VertexCollection.md)
* [Edge Collection](Java/Reference/Graph/EdgeCollection.md)
* [Vertices Manipulation](Java/Reference/Graph/Vertices.md)
* [Edges Manipulation](Java/Reference/Graph/Edges.md)
* [Route](Java/Reference/Route.md)
* [Serialization](Java/Reference/Serialization.md)
* [Manipulating databases/collections](Java/Reference/DatabaseCollection.md)
* [Basic document operations](Java/Reference/Document.md)
* [Multi document operations](Java/Reference/MultiDocument.md)
* [AQL](Java/Reference/AQL.md)
* [Graphs](Java/Reference/Graph.md)
* [Foxx](Java/Reference/Foxx.md)
* [User Management](Java/Reference/UserManagement.md)
# https://@github.com/arangodb/arangodbjs.git;arangodbjs;docs/Drivers;;/
* [ArangoJS - JavaScript Driver](JS/README.md)
* [Getting Started](JS/GettingStarted/README.md)