🏕️
Datahike Tuts
  • Welcome to Datahike Tuts
  • Getting started
  • Basic transacting
  • Appendix
    • Videos to worth watching
    • Useful links
Powered by GitBook
On this page
  • Starting the REPL
  • Loading up datahike and connecting to your db
  • Real talk

Was this helpful?

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

Remember you can only activate this super power once leiningen is installed

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})

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

PreviousWelcome to Datahike TutsNextBasic transacting

Last updated 4 years ago

Was this helpful?

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 .

Did you watch @pithyless from before? Or are you a ?

here
video
quitter