This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-28
Channels
- # announcements (6)
- # beginners (89)
- # boot (1)
- # calva (1)
- # cider (24)
- # cljsrn (19)
- # clojars (2)
- # clojure (102)
- # clojure-europe (2)
- # clojure-italy (9)
- # clojure-nl (1)
- # clojure-spec (6)
- # clojure-uk (56)
- # clojurescript (29)
- # code-reviews (14)
- # cursive (5)
- # data-science (1)
- # datomic (44)
- # duct (1)
- # emacs (10)
- # figwheel-main (5)
- # fulcro (8)
- # graphql (10)
- # hoplon (1)
- # leiningen (7)
- # overtone (17)
- # pathom (8)
- # re-frame (13)
- # slack-help (3)
- # spacemacs (22)
- # sql (2)
- # vim (3)
besides datomic console, are there any notable tools to analyze/report on my database? specifically I'd like to understand how my db is growing or which entities account for the most used storage
Could someone explain to me how to transact entities with components using the client API? I seem to have a critical hole (or two) in my understanding.
{:db/ident :booking/rrule
:db/cardinality :db.cardinality/one
:db/valueType :db.type/ref
:db/isComponent true}
{:db/ident :rrule/frequency
:db/cardinality :db.cardinality/one
:db/valueType :db.type/long}
When I try transacting
{:booking/rrule {:rrule/frequency 1}}
I get errors re: tempids as only valueBut when I transact
{:booking/rrule {:rrule/frequency 1 :_booking tempid}}
I get fault anomalies when I try to pull :booking/rrule attributeshttps://github.com/cognitect-labs/day-of-datomic-cloud/blob/b4103e4a8f14518ed3f6d7f66f56cbf863117974/doc-examples/tutorial.clj#L100 is an example of transacting several component entities
Ok, I looked that over and thought that
{:booking/rrule {:rrule/frequency 1}}
would work, however, I keep getting “tempid used only as value” errorsif that’s a truncated ^ version of your transaction, can you share the full thing please?
Here’s the full transaction:
{:booking/duration "PT1H", :booking/recur-set {:recur-set/rdate [], :recur-set/exdate [], :db/id "bar"}, :booking/student 60842575434612841, :booking/studio 16958867346817130, :booking/dtstart #inst "2015-04-06T21:30:00.000-00:00", :db/id "de92a84f-257c-47b9-bb14-6059bc534c4f", :booking/rrule {:rrule/frequency 1, :rrule/interval :rrule.interval/weeks, :db/id "foo"}, :booking/dtend #inst "2015-04-06T22:30:00.000-00:00", :booking/status :booking.status/scheduled, :booking/instructor 41539549297377384}
If I replace the :db/id in the recur-set and rrule with the parent db/id it succeeds, but then I get faults when querying those attributes
{:booking/duration "PT1H",
:booking/recur-set "bar",
:booking/student 60842575434612841,
:booking/studio 16958867346817130,
:booking/dtstart #inst "2015-04-06T21:30:00.000-00:00",
:db/id "de92a84f-257c-47b9-bb14-6059bc534c4f",
:booking/rrule "foo",
:booking/dtend #inst "2015-04-06T22:30:00.000-00:00",
:booking/status :booking.status/scheduled,
:booking/instructor 41539549297377384}
{:recur-set/rdate [], :recur-set/exdate [], :db/id "bar"}
{:rrule/frequency 1, :rrule/interval :rrule.interval/weeks, :db/id "foo"}
(let [{:keys [instructor student studio dtstart dtend duration status rrule recur-set]} booking-two
booking "baz"
tx-booking #:booking{:instructor instructor
:student student
:studio studio
:dtstart (java.util.Date/from dtstart)
:dtend (java.util.Date/from (t/>> dtstart duration))
:duration (.toString duration)
:status ((fnil keyword "booking.status" "scheduled") "booking.status" status)
:db/id booking
:recur-set "bar"
:rrule "baz"}]
(d/transact conn {:tx-data [tx-booking
{:rrule/frequency 1
:rrule/interval :rrule.interval/weeks
:db/id "baz" }
{:recur-set/rdate []
:recur-set/exdate []
:db/id "bar"}]}))
Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:56).
tempid used only as value in transaction
Just to be sure:
(d/transact conn {:tx-data [{:booking/duration "PT1H",
:booking/recur-set "bar",
:booking/student 60842575434612841,
:booking/studio 16958867346817130,
:booking/dtstart #inst "2015-04-06T21:30:00.000-00:00",
:db/id "de92a84f-257c-47b9-bb14-6059bc534c4f",
:booking/rrule "foo",
:booking/dtend #inst "2015-04-06T22:30:00.000-00:00",
:booking/status :booking.status/scheduled,
:booking/instructor 41539549297377384}
{:recur-set/rdate [], :recur-set/exdate [], :db/id "bar"}
{:rrule/frequency 1, :rrule/interval :rrule.interval/weeks, :db/id "foo"}]})
Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:56).
tempid used only as value in transaction
i would try leaving one of the 2 components in (rrule or recur-set) and then remove one attr at a time from it
Ok, this works:
(d/transact conn {:tx-data [{:booking/duration "PT1H",
:booking/student 60842575434612841,
:booking/studio 16958867346817130,
:booking/dtstart #inst "2015-04-06T21:30:00.000-00:00",
:db/id "de92a84f-257c-47b9-bb14-6059bc534c4f",
:booking/dtend #inst "2015-04-06T22:30:00.000-00:00",
:booking/status :booking.status/scheduled,
:booking/instructor 41539549297377384}
{:recur-set/rdate [], :recur-set/exdate [], :db/id "de92a84f-257c-47b9-bb14-6059bc534c4f", }
{:rrule/frequency 1, :rrule/interval :rrule.interval/weeks, :db/id "de92a84f-257c-47b9-bb14-6059bc534c4f", }]})
(def client (d/client cfg))
(d/list-databases client {})
(d/create-database client {:db-name "marshall-test"})
(def conn (d/connect client {:db-name "marshall-test"}))
(def schema [;; person
{:db/ident :person/email
:db/valueType :db.type/string
:db/unique :db.unique/identity
:db/cardinality :db.cardinality/one}
{:db/ident :person/name
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
:db/isComponent true}
;; name
{:db/ident :name/first
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}
{:db/ident :name/last
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}])
(d/transact conn {:tx-data schema})
(def data [{:person/email ""
:person/name {:name/first "Marshall"}}])
(d/transact conn {:tx-data data})
{:db-before {:database-id "fdeaa432-a7c5-4df3-8259-766ec206974d", :db-name "marshall-test", :t 4, :next-t 5, :type :datomic.client/db}, :db-after {:database-id "fdeaa432-a7c5-4df3-8259-766ec206974d", :db-name "marshall-test", :t 5, :next-t 6, :type :datomic.client/db}, :tx-data [#datom[13194139533317 50 #inst "2018-12-28T21:12:14.808-00:00" 13194139533317 true] #datom[10106710882517060 64 "" 13194139533317 true] #datom[10106710882517060 65 10106710882517061 13194139533317 true] #datom[10106710882517061 66 "Marshall" 13194139533317 true]], :tempids {"datomic.temp-1000005" 10106710882517061}}
@dogenpunk ^ seems to work fine