nervous-systems / hildebrand

Asynchronous DynamoDB client for Clojure & Clojurescript/Node
The Unlicense
66 stars 10 forks source link

Hildebrand Build Status

Clojars Project

Hildebrand is a high-level client for Amazon's Dynamo DB, built on top of Eulalie.

Documentation

Examples

Querying

(require '[hildebrand.channeled :refer [query!]])

(async/into []
  (query! creds :games
          {:user-id [:= "moea"]}
          {:filter [:< [:score] 50]
           :sort :desc
           :limit 10}
          {:chan (async/chan 10 (map :score))}))
;; => [15 10]

Querying + Batched Deletes

(require '[hildebrand.channeled :refer [query! batching-deletes]])

(let [[results errors]
      (->> (query! creds :games
                   {:user-id [:= "moea"]
                    :game-title [:begins-with "Super"]}
                   {:filter [:< [:score] 100]
                    :limit  100})
           (async/split map?))
      {delete-chan :in-chan} (batching-deletes creds {:table :games})]
  (async/pipe results delete-chan))

Clojurescript

All of the functionality (barring the synchronous convenience functions) is exposed via Clojurescript. The implementation specifically targets Node, and uses lein-npm for declaring its dependency on bignumber.js. The wiki contains more information about number handling, which is the only substantial difference from the Clojure implementation.

The specific use-case I had in mind for Node support is writing AWS Lambda functions in Clojurescript.

See the Eulalie README for other Node-relevant details.

Development

Most of the integration tests expect an instance of DynamoDB Local. If the LOCAL_DYNAMO_URL environment variable isn't set, those tests will be skipped.

A couple of the tests expect to get capacity information back from Dynamo, and so can't run against a local instance. If AWS_ACCESS_KEY and AWS_SECRET_KEY are set, these tests'll try to connect and interact with a table (in Dynamo's default region, us-east-1).

Assuming a local Node install, lein cljsbuild once test-none will run the Clojurescript tests. test-advanced will run the tests under :optimizations :advanced.

Contributions welcomed.

See Also

License

hildebrand is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.