cldwalker / datomico

Use datomic with intention revealing names. Ease of use and sticking to datomic's principles are encouraged.
MIT License
49 stars 7 forks source link

couldn't get the examples on the front page to work #3

Closed boxxxie closed 11 years ago

boxxxie commented 11 years ago

also, i'm actually having a lot of trouble geting datomic-simple to work without ring (i haven't tried it with ring yet)

the db is never being set and i'm having to set it manually.

cldwalker commented 11 years ago

Can you be more specific on what examples aren't working? Otherwise I'll be closing

cldwalker commented 11 years ago

Closing. As for other contexts, how could it set db automatically if it doesn't know what context to wrap them in?

zephjc commented 11 years ago

I understand what @boxxxie is talking about here. I added a function 'ready-datomic' (for lack of a better name) to my local copy of datomic-simple, which is suitable for calling from a non-ring program (e.g. a command-line app). It's basically the same as datomic-simple.db/repl-init:

(defn ready-datomic
  [uri]
  (def ^:dynamic *uri* uri)
  (def ^:dynamic *connection* (d/connect *uri*))
  (def ^:dynamic *db* (d/db *connection*)))

I'm sure there's a better way to do this.

cldwalker commented 11 years ago

@zephjc if you (datomic-simple.core/start :repl true) that will be done for you for commandline use

lachie commented 11 years ago

I think it'd be a great idea to rename this and/or mention that it works for command line.

Spent a long, frustrating time wondering why it didn't work until I stumbled on this closed issue.

cldwalker commented 11 years ago

@lachie command line usually refers to bash/zsh shells. Were you using it from there, lein repl or somewhere else?

lachie commented 11 years ago

Yeah exactly, from a shell: $ lein run which uses (defn -main...)

Without :repl true *connection* is unbound when I use <model-namespace>/create et al, even after start. Using the :repl true it works well because its wrapping the inner db functions in the binding goodness.

In my mind repl != command line (i.e. a shell, lein run); is that accurate?

cldwalker commented 11 years ago

@lachie yep. I've renamed the option to :dynamic-vars 7da3bcaf88b36c09d05bf3d7bbc07ef6f7904ab4 . I'll be updating the readme to explain this issue more