# Getting started

## 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
```

{% hint style="info" %}
&#x20;Remember you can only activate this super power once `leiningen` is installed
{% endhint %}

And we're good to go.&#x20;

```
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](https://github.com/replikativ/datahike/blob/development/doc/schema.md).

Now that we've got our config we can really get started.&#x20;

```
=> (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](https://twitter.com/pithyless) from before? Or are you a [quitter](https://www.youtube.com/watch?v=dQw4w9WgXcQ)?
