Articles

Namespaces

The maintainers of arangodb provide a java driver for communicating with an arangodb server. This library provides clojure developers a thin (and incomplete) wrapper of that interface. Much like monger, the java implementation is still visible.

functions are lispy versions of their java counterparts. options are passed as map - with keywords written in :cammelCase - for example {:someOption "a string" :anotherOption ["192.168.1.1", 8888]} For more information about what constitutes a valid option for a method you must consult the java api documentation. As an aside, I considered adding destructuring to give the user nice feedback - but there are just to many of them! If you are interested - have a look at the options namespace and the functions fn-builder and build - we just take the map and create method calls from the keys.

This wrapper exposes most of the available methods - If we look at how the java code is used, in this example a new connecton is being made to a server.

On top of that the is 1 dynamic var *default-doc-class* that is bound to the class com.arangodb.velocypack.VPackSlice

To understand the design of this library it is important to undererstand a little bit about how the java client works.

When you want to send data to ArangoDB the data can be in jsonPOJO (plain old Java object) or a format called a VPackSlice VPackSlices are optimised for fast transmition (by default the java driver uses something called velocy-streams which as you might have guessed have a lot to do with VPackSlices or velocy packs.

As clojurists we like to work with maps and it gets really annoying having to wrap all of your calls in some "to-string" - However, as there are multiple options in how data can be sent, I have tried to be as un-opinionated as possible. I also didn't want to have any dependencies (so no external json libs - pjson is fast but its up to you).

Ok.. so it's broken? Not quite - remeber those multi methods? well, in any call that will send documents to the database, the multimethod serialize-doc is called. Currently it defaults to whatever you give it so in our case a clojure.lang.PersistentArrayMap.

Perhaps you find a better vpack library - but until you do, you can find one under clj-arangodb.velocypack.core This ns provides two functions pack and unpack So lets extend the multimethod

Well look at that! By default calls that return a Entity of some kind are wrapped with adapter/from-entity. by default this calls bean on the object - Entity results are only data - ie they are not handles.