It's nice to see someone writing a relational mapper.
I never got farther than pondering on API design but I share my design
thoughts in case it can be useful to you:
* relations (tables/views/joins) would be a reference type (when
dereferenced they would return a seq or set of maps),
* keys would be namespaced (:album/id and :track/id etc.), foreign
keys use the ns of the foreign table
* join would be implicitly on matching key names (thus the importance
of namespacing)
* transactions would be delimted by a (dbsync ...) forms
* the API would try to be as close as possible of clojure.set
hth,
Christophe
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
--
European Clojure Training Session: Brussels, 23-25/6 http://conj-labs.eu/
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)
I've been thinking about a similar problem.
Most database mappers have three components:
1. The model instance
2. The model collection
3. The model factory
I've been considering how to represent specific model instances in
Clojure. We probably expect a model instance to:
1. Locally cache its value
2. Be able to save changes on request
3. Be able to refresh itself on request
In Clojure, this might look something like:
user=> @user
Log: Fetching data from database
User{:login "jbloggs"}
user=> @user
User{:login "jbloggs"}
user=> (refresh user)
nil
user=> @user
Log: Fetching data from database
User{:login "jbloggs"}
user=> (update user assoc :name "Joe Bloggs")
User{:login "jbloggs", :name "Joe Bloggs"}
user=> (save user)
Log: Saving data to database
User{:login "jbloggs", :name "Joe Bloggs"}
- James