-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl
More file actions
35 lines (24 loc) · 834 Bytes
/
repl
File metadata and controls
35 lines (24 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(use 'db-fns-test)
(require '[datomic.api :as d])
(require '[db-fns :refer :all])
(def conn (make-db))
(def pardal-id (add-user! conn "caio" "Caio" "Pardal"))
(def andre-id (add-user! conn "andre" "Andre" "Nieri"))
(def msg1-id (send-message! conn pardal-id "Hey, Andre!," andre-id))
(def db0 (d/db conn))
(d/pull db0 '[*] pardal-id)
(d/pull db0 '[:user/firstname] pardal-id)
(def msg1 (d/entity db0 msg1-id))
msg1
(:message/text msg1)
msg1
(:message/from-user-id msg1)
msg1
(:user/firstname (:message/from-user-id msg1))
@(d/transact conn [{:db/id pardal-id, :user/firstname "Caio!"}])
(def db1 (d/db conn))
(def db1-h (d/history db1))
(defn firstnames [db] (d/q '[:find ?username ?firstname :where [?id :user/firstname ?firstname][?id :user/username ?username]] db))
(firstnames db0)
(firstnames db1)
(firstnames db1-h)