Created
June 27, 2012 14:45
-
-
Save ulsa/3004531 to your computer and use it in GitHub Desktop.
Finding Out Who Changed What with Datomic
This file contains 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=> (distinct (map :e (d/datoms (d/since (db conn) #inst "2012-06-25T10:33:16.436-00:00") :eavt))) | |
(13194139534683 17592186045460) |
This file contains 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=> (->> (-> (db conn) | |
(d/since #inst "2012-06-25T10:33:16.436-00:00") | |
(d/datoms :eavt)) | |
(map :e) | |
distinct) | |
(13194139534683 17592186045460) |
This file contains 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=> (count (q '[:find ?c ?n | |
:where [?c :community/name ?n] | |
[ (.compareTo ?n "B") ?res ] | |
[ (< ?res 0) ] ] (db conn))) | |
9 |
This file contains 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 '[datomic.api :only (q db) :as d]) |
This file contains 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.pprint) | |
user=> (pprint (seq (q '[:find ?c ?n | |
:where [?c :community/name ?n] | |
[ (.compareTo ?n "B") ?res ] | |
[ (< ?res 0) ] ] (db conn)))) | |
([17592186045463 "Aurora Seattle"] | |
[17592186045454 "All About South Park"] | |
[17592186045448 "Alki News/Alki Community Council"] | |
[17592186045446 "Alki News"] | |
[17592186045460 "At Large in Ballard"] | |
[17592186045457 "ArtsWest"] | |
[17592186045451 "All About Belltown"] | |
[17592186045440 "15th Ave Community"] | |
[17592186045443 "Admiral Neighborhood Association"]) | |
nil |
This file contains 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 (seq (q '[:find ?c ?n ?t | |
:where [?tx :db/txInstant ?t] | |
[?c :community/name ?n ?tx] | |
[ (.compareTo ?n "B") ?res ] | |
[ (< ?res 0) ] ] (db conn)))) | |
([17592186045451 "All About Belltown" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045463 "Aurora Seattle" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045460 "At Large in Ballard" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045454 "All About South Park" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045457 "ArtsWest" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045440 "15th Ave Community" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045446 "Alki News" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045443 "Admiral Neighborhood Association" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045448 "Alki News/Alki Community Council" | |
#inst "2012-06-25T10:33:16.436-00:00"]) | |
nil |
This file contains 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 (seq (q '[:find ?c ?n ?txInstant | |
:where [?tx :db/txInstant ?txInstant] | |
[?c :community/name ?n ?tx] | |
[ (.compareTo ?n "B") ?res ] | |
[ (< ?res 0) ] ] (db conn)))) | |
([17592186045451 "All About Belltown" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045463 "Aurora Seattle" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045460 "At Large in Ballard renamed" | |
#inst "2012-06-25T10:55:47.363-00:00"] | |
[17592186045454 "All About South Park" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045457 "ArtsWest" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045440 "15th Ave Community" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045446 "Alki News" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045443 "Admiral Neighborhood Association" | |
#inst "2012-06-25T10:33:16.436-00:00"] | |
[17592186045448 "Alki News/Alki Community Council" | |
#inst "2012-06-25T10:33:16.436-00:00"]) | |
nil |
This file contains 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=> (class #inst "2012-06-25T10:33:16.436-00:00") | |
java.util.Date | |
user=> (.getTime #inst "2012-06-25T10:33:16.436-00:00") | |
1340620396436 |
This file contains 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 renamed"}]) |
This file contains 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 uri "datomic:mem://seattle") | |
user=> (d/create-database uri) | |
user=> (def conn (d/connect uri)) | |
user=> @(d/transact conn (read-string (slurp "samples/seattle/seattle-schema.dtm"))) | |
user=> @(d/transact conn (read-string (slurp "samples/seattle/seattle-data0.dtm"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment