Alternative defdbop macro

38 views
Skip to first unread message

Jesper Andre Lyngesen Pedersen

unread,
Feb 26, 2014, 6:10:00 PM2/26/14
to clojure...@googlegroups.com
Hi,

  I was sufficiently annoyed with the fact that one could not operate on a second database while in the context of another, that I've created a fork of the otherwise excellent clutch library: https://github.com/jalpedersen/clutch

The new version creates two distinct versions of the given function: One taking the database from the thread-bound *database* and another which takes it from it's first argument. The latter has "-with-db" appended to the function name

Example:

(put-document-with-db my-db {:name "Bob"})

(with-db db
  (put-document {:name "Alice"})
  (put-document-with-db another-db {:name "Cecil"}))


The idea was taken from the comments for an article by Chas Emerick himself: http://cemerick.com/2011/10/17/a-la-carte-configuration-in-clojure-apis/


Reply all
Reply to author
Forward
0 new messages