{"id":15286892,"url":"https://github.com/beoliver/clj-arangodb","last_synced_at":"2025-04-13T03:57:07.124Z","repository":{"id":62431298,"uuid":"104779120","full_name":"beoliver/clj-arangodb","owner":"beoliver","description":"Clojure wrappers for the arangodb java client and velocypack libs","archived":false,"fork":false,"pushed_at":"2023-02-28T17:15:48.000Z","size":132,"stargazers_count":11,"open_issues_count":4,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T03:57:01.362Z","etag":null,"topics":["arangodb","clojure","database","driver","interop"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beoliver.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T17:13:23.000Z","updated_at":"2024-08-26T20:11:22.000Z","dependencies_parsed_at":"2023-01-21T14:17:05.150Z","dependency_job_id":null,"html_url":"https://github.com/beoliver/clj-arangodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beoliver%2Fclj-arangodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beoliver%2Fclj-arangodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beoliver%2Fclj-arangodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beoliver%2Fclj-arangodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beoliver","download_url":"https://codeload.github.com/beoliver/clj-arangodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661707,"owners_count":21141450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arangodb","clojure","database","driver","interop"],"created_at":"2024-09-30T15:18:52.709Z","updated_at":"2025-04-13T03:57:07.094Z","avatar_url":"https://github.com/beoliver.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj-arangodb\n\n[![Clojars Project](https://img.shields.io/clojars/v/beoliver/clj-arangodb.svg)](https://clojars.org/beoliver/clj-arangodb)\n[![CircleCI](https://circleci.com/gh/beoliver/clj-arangodb.svg?style=shield)](https://circleci.com/gh/beoliver/clj-arangodb)\n\n### A Clojure interface for the `arangodb-java-driver`\n\nThe maintainers of arangodb provide a [java driver](https://www.arangodb.com/docs/stable/drivers/java-getting-started.html) for communicating with an arangodb server. `clj-arangodb` provides a _thin_ (and incomplete) abstraction.\n\n## Getting started\n\nFor the most up to date information it is best to consult the official java [documentation](https://www.arangodb.com/docs/stable/drivers/java-reference.html). In general functions are lispy versions of their java counterparts (methods).\n\nOptions are passed as maps. Keys can be _keywords_ or _strings_, but should be written using `cammelCase`. If an option takes multiple arguments then a vector should be used.\n\nFor more information about what constitutes a valid option for a method you must consult the java api documentation.\n\n### Creating a connection\n\nAssuming that you have created a `user` in the arango database...\n\n```clojure\n(ns user\n  (:require [clj-arangodb.arangodb.core :as a]\n            [clj-arangodb.arangodb.databases :as d]\n            [clj-arangodb.arangodb.collections :as c]\n            [clj-arangodb.arangodb.adapter :as adapter])\n  (:import [com.arangodb Protocol]\n           [com.arangodb.entity BaseDocument]\n           [com.arangodb.velocypack VPackSlice]))\n\n(defonce conn ;; connections are thread safe\n  (let [config {:useProtocol Protocol/VST\n                :user \"test\"\n                :host [\"127.0.0.1\" 8529]}]\n    (a/connect config)))\n```\n\n### Databases\n\n```clojure\nuser\u003e (a/database? conn \"testDB\")\nfalse\nuser\u003e (def db (a/create-and-get-database conn \"testDB\"))\n#'user/db\nuser\u003e db\n#object[com.arangodb.internal.ArangoDatabaseImpl 0x38f9457a \"com.arangodb.internal.ArangoDatabaseImpl@38f9457a\"]\nuser\u003e (a/database? conn \"testDB\")\ntrue\nuser\u003e (a/get-databases conn)\n[\"_system\" \"testDB\"]\n```\n\n### Collections\n\n```clojure\nuser\u003e (d/collection? db \"testColl\")\nfalse\nuser\u003e (def coll (d/create-and-get-collection db \"testColl\"))\n#'user/coll\nuser\u003e (d/collection? db \"testColl\")\ntrue\nuser\u003e (def coll-again (d/get-collection db \"testColl\"))\n#'user/coll-again\nuser\u003e (= coll coll-again)\nfalse\nuser\u003e coll\n#object[com.arangodb.internal.ArangoCollectionImpl 0x23266a4f \"com.arangodb.internal.ArangoCollectionImpl@23266a4f\"]\nuser\u003e coll-again\n#object[com.arangodb.internal.ArangoCollectionImpl 0x33859f41 \"com.arangodb.internal.ArangoCollectionImpl@33859f41\"]\nuser\u003e (= (adapter/from-entity (:info (bean coll)))\n         (adapter/from-entity (:info (bean coll-again))))\ntrue\n```\n\nBy default functions that return a `Entity` of some kind are wrapped with `adapter/from-entity`.\n`Entity` results are only data - ie they are not handles.\nThe default for this is to call `bean` and then examines the values under the keys.\nIn general if the entity contains results, these results are _not_\ndesearialzed. all sub classes are - (some are converted to string to give sensible data)\n\n### Documents\n\ninserting a document\n\n```clojure\nuser\u003e (c/insert-document coll {:hello \"world\"})\n{:class com.arangodb.entity.DocumentCreateEntity,\n :id \"testColl/34730\",\n :key \"34730\",\n :new nil,\n :old nil,\n :rev \"_bH1Uxmq---\"}\n```\n\n#### Retrieving a document.\n\nBy default when retreiving a document the `VPackSlice` class is used. This is then parsed using the [cheshire(https://github.com/dakrone/cheshire) json library.\n\n```clojure\nuser\u003e (c/get-document coll \"34730\")\n{:_key \"34730\",\n :_id \"testColl/34730\",\n :_rev \"_bH1Uxmq---\",\n :hello \"world\"}\n\nuser\u003e (c/get-document coll \"34730\" VPackSlice)\n{:_key \"34730\",\n :_id \"testColl/34730\",\n :_rev \"_bH1Uxmq---\",\n :hello \"world\"}\n```\n\nBy passing a class as well we can get a different type back.\nThe `BaseDocument` (belonging to ArangoDB) class is converted by calling `bean`.\n\n```clojure\nuser\u003e (c/get-document coll \"34730\" BaseDocument)\n{:class com.arangodb.entity.BaseDocument,\n :id \"testColl/34730\",\n :key \"34730\",\n :properties {\"hello\" \"world\"},\n :revision \"_bH1Uxmq---\"}\n```\n\n```clojure\nuser\u003e (c/get-document coll \"34730\" String)\n\"{\\\"_key\\\":\\\"34730\\\",\\\"_id\\\":\\\"testColl\\\\/34730\\\",\\\"_rev\\\":\\\"_bH1Uxmq---\\\",\\\"hello\\\":\\\"world\\\"}\"\n```\n\n```clojure\nuser\u003e (c/get-document coll \"34730\" java.util.Map)\n{\"_key\" \"34730\",\n \"_id\" \"testColl/34730\",\n \"_rev\" \"_bH1Uxmq---\",\n \"hello\" \"world\"}\n```\n\nIf you want to use a custom json serializer/deserializer then you can extend the multimethods `serialize-doc` and `deserialize-doc` for the `String` class.\n\n## AQL\n\nThe AQL query syntax can be represented as clojure data structures, there is no EBFN document at the moment so you will have to read the source file, an example taken from one of the tests:\nIn this example the FOR statement is used to execute a graph query\n\n```clojure\n(ns user\n  (:require [clj-arangodb.arangodb.databases :as d]\n            [clj-arangodb.arangodb.test-data :as td]\n            [clj-arangodb.arangodb.helper :as h]))\n```\n\n```clojure\nuser\u003e (td/init-game-of-thrones-db)\nnil\nuser\u003e (h/with-db [db td/game-of-thrones-db-label]\n        (let [query [:FOR [\"c\" \"Characters\"]\n                     [:FILTER [:EQ \"c.name\" \"\\\"Bran\\\"\"]]\n                     [:FOR [\"v\" {:start \"c\"\n                                 :type :outbound\n                                 :depth [1 1]\n                                 :collections [\"ChildOf\"]}]\n                      [:RETURN \"v.name\"]]]]\n          (println (vec (d/query db query String)))))\n[Ned Catelyn]\n```\n\nHave a play - and remeber the multimethods! - if you don't like the data you are getting, change it...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeoliver%2Fclj-arangodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeoliver%2Fclj-arangodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeoliver%2Fclj-arangodb/lists"}