links to nyse's :start / :stop

This commit is contained in:
anatoly 2015-10-20 08:36:00 -04:00
parent cd443aed76
commit cd6a92ac58
3 changed files with 8 additions and 5 deletions

View file

@ -102,7 +102,7 @@ this `app-config`, being top level, can be used in other namespaces, including t
```
[here](https://github.com/tolitius/mount/blob/master/test/mount/nyse.clj)
is an example of a Datomic connection that "depends" on the similar `app-config`.
is an example of a Datomic connection that "depends" on a similar `app-config`.
## The Importance of Being Reloadable
@ -160,7 +160,10 @@ dev=> (reset)
notice that it stopped and started again.
After the REPL was just started, schema was not created. Since the app was `(reset)`, it was brought to that starting point, so no schema again:
In nyse's connection [:stop](https://github.com/tolitius/mount/blob/a7424d4895ad7abe4933b425e718a6bdf1a0c22f/test/mount/nyse.clj#L18)
function database is deleted. Hence after `(reset)` was called the app was brought its starting point: database was created by the
[:start](https://github.com/tolitius/mount/blob/a7424d4895ad7abe4933b425e718a6bdf1a0c22f/test/mount/nyse.clj#L11) function,
but no schema again:
```clojure
dev=> (find-orders "GOOG")
@ -181,7 +184,7 @@ dev=> (find-orders "AAPL")
({:db/id 17592186045418, :order/symbol "AAPL", :order/bid 111.712M, :order/qty 250, :order/offer 111.811M})
```
## license
## License
Copyright © 2015 tolitius

View file

@ -40,7 +40,7 @@
:order/qty qty}]))
(defn find-orders [ticker] ;; can take connection as param
(defn find-orders [ticker] ;; can take connection as param
(let [orders (d/q '[:find ?e :in $ ?ticker
:where [?e :order/symbol ?ticker]]
(d/db nyse/conn) ticker)]

View file

@ -14,7 +14,7 @@
(defn disconnect [conf conn]
(let [uri (get-in conf [:datomic :uri])]
(info "disconnecting from " uri)
(.release conn) ;; usually it's no released, here just to illustrate the access to connection on (stop)
(.release conn) ;; usually it's not released, here just to illustrate the access to connection on (stop)
(d/delete-database uri)))
(defstate conn :start (new-connection app-config)