Getting started
Fire up the REPLs!!
Starting the REPL
Becoming a super hero is a fairly straight forward process:
$ git clone https://github.com/alekcz/datahike-starter.git
$ cd datahike-starter
$ lein repl
And we're good to go.
nREPL server started on port 63162 on host 127.0.0.1 - nrepl://127.0.0.1:63162
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.0
OpenJDK 64-Bit Server VM GraalVM CE 20.0.0 1.8.0_242-b06
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
datahike-starter.core=>
Loading up datahike and connecting to your db
=> (require '[datahike.api :as d]) ; require datahike
Before initiating a connection we need to set up the config for it
=> (def config {:store {:backend :mem}
:schema-flexibility :read
:keep-history? true})
This config creates an in-memory instance of datahike with the schema only apply on read and history enable. You can read more about schemas here.
Now that we've got our config we can really get started.
=> (d/database-exists? config) ; check if it exists
; ...
; false
=> (d/connect config) ; this fails
; ...
; Backend does not exist.
=> (d/create-database config) ; so let's create it
; ...
; nil
=> (d/database-exists? config) ; and now it exists
; ...
; true
=> (d/connect config) ; And we're in
Real talk
Did you watch @pithyless video from before? Or are you a quitter?
Last updated
Was this helpful?