This is a scratchpad project to experiment with approaches for database access on Macchiato. Treat this project as back-of-the-napkin scribblings. The whole point is to try different things and see what ends up being cleaner and more Clojuric.
Chances are little or none of the code you'll see here has been library-fied. As sections reach that point, we'll move them into independent projects in the Macchiato Framework organization.
Think things could be done better? Great, reach out! You can find us on:
- #macchiato on Matrix, which mirrors
- #macchiato on Clojurians
While the Clojurians channel is still the canonical endpoint, it is subject to Slack's periodic history deletion. You can find the full channel history on Matrix/Riot.
Almost everything.
- Extracting database access into its own namespace so we can easily turn it into a library
- Tests
- Migrations (postgrator might be useful here)
TODO:
- A more polished HugSQL equivalent. A draft version which gets queries from a set of files is at
macchiato.sql
. - Further review of type coercion. There's a working example of type parsers on
machtest.db
- Node.js needs to be installed to run the application.
- You'll need a PostgreSQL database running on the standard port. Check namespace
machtest.db
for the default database configuration. - Run the
setup-dev-db.sh
script from the project's root folder to create a user, a sample database and table, and some data.
run the following command in the terminal to install NPM modules and start Figwheel:
lein build
Run node
in another terminal:
node target/out/machtest.js
Check machtest.routes
for the http entry points and machtest.db
for the database functions.
Once Figwheel and node are running, you can connect to the remote REPL at localhost:7000
.
Type (cljs)
in the REPL to connect to Figwheel ClojureSrcipt REPL.
Whereas the dev version has only the one thread, the release version uses a cluster. To build:
lein package
Run the release version:
node target/release/machtest.js
Distributed under the MIT License