Open olymk2 opened 3 years ago
You would configure clip to run your functions. For example, you'd create a closure over your ring handler(s) to pass it the db. Here's an example of doing that in the todo example linked in the README: https://github.com/prestancedesign/todo-backend-reitit/blob/c3d5974f679203f200089ca10f40fda75b7e6e33/resources/config.edn#L12
lol I really don't get something, it looks like its being passed to the handler ie todo-backend.core/app-routes but looking at the code here
it does not take a parameter, I guess ring/ring-handler could be storing a fn in app-routes which takes db.
then in this piece of code, it looks like its actually setting up the db from env and storing the instance in db rather than using clip at which point its global scope in that file and makes me wonder why its being used in clip.
I admit something in there are unfamiliar like nextjdbc, but to me the point is I use clip to start my db and http server in order and some how make the value available, I think mount for example inserts namespaces which you can import to get the reference to your instances.
Not tried using a state management library, I have followed the examples and have everything working.
What I do not get is how I reference state, so say I bring up the db in start how do I then access the db connection, normally I would (defonce crux-db (run-crux)) then reference crux-db in my code, I have found clip/ref but that seems not to return an instance of the command run in startup of clip.
how would I get the connection for a db like postgres or crux ?
The only examples I could find seem to pass the connection in to all functions instead of setting it globally.