Created
June 27, 2012 15:23
-
-
Save ulsa/3004813 to your computer and use it in GitHub Desktop.
Find Out Who Changed What with Datomic, 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> @(d/transact conn | |
[{:db/id #db/id[:db.part/db] | |
:db/ident :audit/user | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db/index true | |
:db.install/_attribute :db.part/db}]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> @(d/transact conn | |
[{:db/id #db/id[:db.part/db] | |
:db/ident :audit/user | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db/index true | |
:db.install/_attribute :db.part/db}]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> @(d/transact conn | |
[{:db/id 17592186045460 :community/name "At Large in Ballard"} | |
[:db/add (d/tempid :db.part/tx) :audit/user "ulsa" ]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (def changed (->> (-> (db conn) | |
(d/since #inst "2012-06-25T10:33:16.436-00:00") | |
(d/datoms :eavt)) | |
(map :e) | |
distinct)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (def changed (->> (-> (db conn) | |
(d/since #inst "2012-06-25T10:33:16.436-00:00") | |
(d/datoms :eavt)) | |
(map :e) | |
distinct)) | |
user=> changed | |
(0 72 13194139534683 13194139534684 13194139534685 17592186045460) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (def changed (->> (-> (db conn) | |
(d/since #inst "2012-06-25T11:13:23.642-00:00") | |
(d/datoms :eavt)) | |
(map :e) | |
distinct)) | |
user=> changed | |
(13194139534685 17592186045460) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (use '[clojure.walk :only (macroexpand-all)]) | |
user=> (macroexpand-all '(-> x (h 3) (g 2) (f 1))) | |
(f (g (h x 3) 2) 1) | |
user=> (macroexpand-all '(->> x (h 3) (g 2) (f 1))) | |
(f 1 (g 2 (h 3 x))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (macroexpand-all | |
'(->> (-> (db conn) | |
(d/since #inst "2012-06-25T10:33:16.436-00:00") | |
(d/datoms :eavt)) | |
(map :e) | |
distinct)) | |
(distinct (map :e (d/datoms (d/since (db conn) #inst "2012-06-25T10:33:16.436-00:00") :eavt))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (pprint (map #(seq (d/entity (db conn) %)) changed)) | |
(([:db/txInstant #inst "2012-06-25T10:55:47.363-00:00"]) | |
([:community/type :community.type/blog] | |
[:community/orgtype :community.orgtype/commercial] | |
[:community/category #{"news" "human interest"}] | |
[:community/neighborhood {:db/id 17592186045459}] | |
[:community/url "http://blog.seattlepi.com/ballard/"] | |
[:community/name "At Large in Ballard renamed"])) | |
nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (pprint (map #(seq (d/entity (db conn) %)) changed)) | |
(([:audit/user "ulsa"] | |
[:db/txInstant #inst "2012-06-25T11:13:23.643-00:00"]) | |
([:community/type :community.type/blog] | |
[:community/orgtype :community.orgtype/commercial] | |
[:community/category #{"news" "human interest"}] | |
[:community/neighborhood {:db/id 17592186045459}] | |
[:community/url "http://blog.seattlepi.com/ballard/"] | |
[:community/name "At Large in Ballard"])) | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment