This is a very simple example for how to use mongo-db using the tesla-mongo-connect addon to tesla-microservice.
To start the application you can either use
-
a mongo-db running on localhost (or whatever you change the config to in [default.properties](ls resources/default.properties)). Then you can start the application with
lein run
-
an embedded mongodb provided by embongo. Start the application with
lein embongo run
.
First some data is written into the collection testcol
during starting up the system in example_system.clj:
(mongo/update-upserting! (:mongo started) "testcol" {:_id "myId"}
{:_id "myId"
:foo "bar"
:info "This was upserted into mongo in example-system.clj"})
The project contains a very simple page, which is dependent on :mongo
in tesla-mongo-connect. If you call http://localhost:8080/example
the data is read out of mongo and rendered into the html-response in page.clj:
(mongo/find-one-checked! (:mongo self) "testcol" {})