Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JNoSQL/Diana/ArangoDB"

< JNoSQL‎ | Diana
 
(No difference)

Latest revision as of 02:59, 17 November 2017

ArangoDB

ArangoDB is a NoSQL multi-model database developed by triAGENS GmbH. It has been referred to as the most popular NoSQL database available that has an open source license. It has also been referred to as a universal database. Its creators refer to it as a "native multi-model" database to indicate that it was designed specifically to allow key/value, document, and graph data to be stored together and queried with a common language.


Maven Project

To use ArandoDB driver in a Maven Project:

        <dependency>
            <groupId>org.jnosql.diana</groupId>
            <artifactId>arangodb-driver</artifactId>
            <version>version</version>
        </dependency>

E.g:

        <dependency>
            <groupId>org.jnosql.diana</groupId>
            <artifactId>arangodb-driver</artifactId>
            <version>0.0.1</version>
        </dependency>


Key Value

The ArangoDB key-value implementation uses the ArangoDBKeyValueConfiguration to the configuration. This class has configurations methods such as host, port, timeout, user, password. Beyond the method also it can read a configuration from arangodb.properties file.


  • arangodb.host
  • arangodb.port
  • arangodb.timeout
  • arangodb.user
  • arangodb.password
  • arangodb.usessl
  • arangodb.chunksize


Sample Code

public class App {


    public static void main(String[] args) {

        KeyValueConfiguration configuration = new ArangoDBKeyValueConfiguration();
        try (BucketManagerFactory managerFactory = configuration.get()) {
            BucketManager bucket = managerFactory.getBucketManager("bucket");
            List<String> list = managerFactory.getList("bucketList", String.class);
            Set<String> set = managerFactory.getSet("bucketSet", String.class);
            Map<String, Integer> map = managerFactory.getMap("bucketList", String.class, Integer.class);
            Queue<String> queue = managerFactory.getQueue("queueList", String.class);
            bucket.put("key", "value");
            Optional<Value> value = bucket.get("key");
        }


    }
}


Document

The ArangoDB document implementation uses the ArangoDBDocumentConfiguration to the configuration. This class has configurations methods such as host, port, timeout, user, password. Beyond the method also it can read a configuration from arangodb.properties file.


  • arangodb.host
  • arangodb.port
  • arangodb.timeout
  • arangodb.user
  • arangodb.password
  • arangodb.usessl
  • arangodb.chunksize


Sample Code


public class App {

    public static final String DATABASE = "database";
    public static final String DOCUMENT_COLLECTION = "person";

    public static void main(String[] args)  {
        DocumentConfiguration configuration = new ArangoDBDocumentConfiguration();
        try(DocumentCollectionManagerFactory collectionFactory = configuration.get();) {
            DocumentCollectionManager collectionManager = collectionFactory.get(DATABASE);

            DocumentEntity entity = DocumentEntity.of(DOCUMENT_COLLECTION);
            entity.add(Document.of("name", "Daniel Soro"));
            entity.add(Document.of("age", 26));

            DocumentEntity entitySaved = collectionManager.save(entity);
            Optional<Document> id = entitySaved.find("_id");

            DocumentQuery query = select().from(DOCUMENT_COLLECTION).where(DocumentCondition.eq(id.get())).build();
            List<DocumentEntity> documentsFound = collectionManager.select(query);
            String aql = "FOR a IN person FILTER a.name == @name RETURN a";
            List<DocumentEntity> entities = entityManager.aql(aql, singletonMap("name", "Poliana"));


        }
    }
}

Links

Back to the top