Closed boxxxie closed 11 years ago
Can you be more specific on what examples aren't working? Otherwise I'll be closing
Closing. As for other contexts, how could it set db automatically if it doesn't know what context to wrap them in?
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.
@zephjc if you (datomic-simple.core/start :repl true)
that will be done for you for commandline use
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.
@lachie command line usually refers to bash/zsh shells. Were you using it from there, lein repl or somewhere else?
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?
@lachie yep. I've renamed the option to :dynamic-vars 7da3bcaf88b36c09d05bf3d7bbc07ef6f7904ab4 . I'll be updating the readme to explain this issue more
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.