ArangoDB v3.4 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent version here: Latest Docs
Manipulating documents
ArangoOperations.exists
ArangoOperations.exists(String id, Class<?> entityClass) : boolean
Checks whether the document exists by reading a single document head
Arguments
-
id:
StringThe id or key of the document
-
entityClass:
Class<T>The entity class which represents the collection
Examples
@Autowired ArangoOperations template;
boolean exists = template.exists("some-id", MyObject.class);
ArangoOperations.find
ArangoOperations.find(String id, Class<T> entityClass, DocumentReadOptions options) : Optional<T>
Retrieves the document with the given id from a collection.
Arguments
-
id:
StringThe id or key of the document
-
entityClass:
Class<T>The entity class which represents the collection
-
options:
DocumentReadOptions-
ifNoneMatch:
StringDocument revision must not contain If-None-Match
-
ifMatch:
StringDocument revision must contain If-Match
-
catchException:
BooleanWhether or not catch possible thrown exceptions
-
Examples
@Autowired ArangoOperations template;
Optional<MyObject> doc = template.find("some-id", MyObject.class, new DocumentReadOptions());
ArangoOperations.repsert
ArangoOperations.repsert(T value) : void
Creates a new document from the given document, unless there is already a document with the id given. In that case it replaces the document.
Arguments
-
value:
TA representation of a single document
Examples
@Autowired ArangoOperations template;
MyObject myObj = ...
template.repsert(myObj);
ArangoOperations.insert
ArangoOperations.insert(T value, DocumentCreateOptions options) : DocumentEntity
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:
TA representation of a single document
-
options:
DocumentCreateOptions-
waitForSync:
BooleanWait until document has been synced to disk.
-
returnNew:
BooleanReturn additionally the complete new document under the attribute new in the result.
-
returnOld:
BooleanAdditionally return the complete old document under the attribute old in the result. Only available if the overwrite option is used.
-
overwrite:
BooleanIf 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:
BooleanIf 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
@Autowired ArangoOperations template;
MyObject myObj = ...
DocumentEntity info = template.insert(myObj, new DocumentCreateOptions());
ArangoOperations.replace
ArangoOperations.replace(String id, T value, DocumentReplaceOptions options) : DocumentEntity
Replaces the document with id with the one in the body, provided there is such a document and no precondition is violated.
Arguments
-
id:
StringThe id or key of the document
-
value:
TA representation of a single document
-
options:
DocumentReplaceOptions-
waitForSync:
BooleanWait until document has been synced to disk.
-
ignoreRevs:
BooleanBy 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:
StringReplace a document based on target revision
-
returnNew:
BooleanReturn additionally the complete new document under the attribute new in the result.
-
returnOld:
BooleanAdditionally return the complete old document under the attribute old in the result. Only available if the overwrite option is used.
-
silent:
BooleanIf 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
@Autowired ArangoOperations template;
MyObject myObj = ...
DocumentEntity info = template.replace("some-id", myObj, new DocumentReplaceOptions());
ArangoOperations.update
ArangoOperations.update(String id, T value, DocumentUpdateOptions options) : DocumentEntity
Partially updates the document identified by document id or key. The value must contain a document with the attributes to patch (the patch document). All attributes from the patch document will be added to the existing document if they do not yet exist, and overwritten in the existing document if they do exist there.
Arguments
-
id:
StringThe id or key of the document
-
value:
TA representation of a single document
-
options:
DocumentUpdateOptions-
waitForSync:
BooleanWait until document has been synced to disk.
-
ignoreRevs:
BooleanBy 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:
StringReplace a document based on target revision
-
returnNew:
BooleanReturn additionally the complete new document under the attribute new in the result.
-
returnOld:
BooleanAdditionally return the complete old document under the attribute old in the result. Only available if the overwrite option is used.
-
silent:
BooleanIf 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
@Autowired ArangoOperations template;
MyObject myObj = ...
DocumentEntity info = template.update("some-id", myObj, new DocumentReplaceOptions());
ArangoOperations.delete
ArangoOperations.delete(String id, Class<?> entityClass, DocumentDeleteOptions options) : DocumentEntity
Deletes the document with the given id from a collection.
Arguments
-
id:
StringThe id or key of the document
-
entityClass:
Class<T>The entity class which represents the collection
-
options:
DocumentDeleteOptions-
waitForSync:
BooleanWait until document has been synced to disk.
-
ifMatch:
StringReplace a document based on target revision
-
returnOld:
BooleanAdditionally return the complete old document under the attribute old in the result. Only available if the overwrite option is used.
-
silent:
BooleanIf 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
@Autowired ArangoOperations template;
template.delete("some-id", MyObject.class, new DocumentDeleteOptions());