Skip to content

Instantly share code, notes, and snippets.

@felipefpx
Last active August 5, 2023 16:56
Show Gist options
  • Save felipefpx/1525378a023148e984cc11d84ab44c60 to your computer and use it in GitHub Desktop.
Save felipefpx/1525378a023148e984cc11d84ab44c60 to your computer and use it in GitHub Desktop.
Getting Started with Datomic
### Download and setup
1. Initially, download the Datomic Pro version on the official website: https://docs.datomic.com/pro/getting-started/get-datomic.html
2. Unzip the zip file and move the folder for your desired path, in this case, it will be on `$HOME/datomic`
3. Prepare the config file on `$HOME/datomic/config`, there are some examples on `$HOME/datomic/config/samples`
4. Add the aliases to your terminal startup file (e.g. `~/.bashrc` or `~/.zshrc`) that will be useful for dealing with your Datomic:
```
# To start Datomic REPL:
alias datomic-repl="$HOME/datomic/bin/repl"
# To start Datomic dev transactor:
alias datomic-dev-transactor="$HOME/datomic/bin/transactor -Ddatomic.printConnectionInfo=true config/dev-transactor.properties"
```
5. Restart your terminal windows and run `$ datomic-dev-transactor`, it will start the Datomic and give you its URL.
### Prepare a leiningen project to use Datomic Pro
Based on https://docs.datomic.com/pro/peer/integrating-peer-lib.html
1. In my case, I prefered to install maven using Homebrew `$ brew install mvn`. You can find Homebrew setup steps on `https://brew.sh/`
2. Navigate to `$HOME/datomic` using the terminal and run `$ ./bin/maven-install` to prepare maven
3. Add the peer dependency to your project.clj: `:dependencies [[com.datomic/peer "1.0.6735"]]`
4. Run a repl to create your database using `$ lein repl` in your project folder
```
(require '[datomic.api :as d])
(def db-uri "<transactor-uri>/<db-name>")
(d/create-database db-uri)
```
The output should be `true` for success on the database creation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment