This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-10
Channels
- # admin-announcements (50)
- # beginners (4)
- # boot (31)
- # cider (25)
- # clojure (120)
- # clojure-brasil (1)
- # clojure-germany (2)
- # clojure-india (9)
- # clojure-italy (6)
- # clojure-japan (104)
- # clojure-nl (13)
- # clojure-norway (1)
- # clojure-russia (6)
- # clojure-sg (23)
- # clojure-spain (37)
- # clojure-turkiye (2)
- # clojurescript (115)
- # core-matrix (1)
- # datomic (63)
- # editors (32)
- # euroclojure (56)
- # events (6)
- # ldnclj (71)
- # off-topic (27)
- # onyx (7)
- # overtone (2)
- # reading-clojure (16)
- # reagent (5)
- # slack-help (10)
@bhagany, @ericfode: i asked about this, and it’s by design that pull does this. i guess they didn’t want to hide any other data that might be on the enum entity, which is what would happen if they short-circuited it
another thing to note about pull; it doesn’t return :db/id
yeah, it's understandable, once you think about it. just a little unexpected after using the entity api.
@robert-stuttaford: I probably can't make it to the hangout, because I'm supposed to work (read: make billable hours) then
@robert-stuttaford: but if it's going to be recorded, I'm interested in viewing it later
@robert-stuttaford: your awesome, thankyou.
is there any benefit to :user/id
+ :user/email
idents as opposed to :user-id
+ :user-email
? The Datomic docs seem to prefer namespaces, but the “bare” version would allow validating maps passed into datomic with Prismatic schema...
@ericfode: The map returned by transact contains an entry with the :tempids key that contains the created (or identified if they already exist) entity ids
if you’re using tempids from the tempid function, this might also be helpful: http://docs.datomic.com/clojure/#datomic.api/resolve-tempid
@stig: think that's just the datomic team's standard, I don't think there's a real win from them (though I do prefer namespaces personally)
@stig, @tcrayford, i think namespaced keys index better
user/* lives together, etc
@stig, you can use ns’d kws with Schema
@robert-stuttaford: reminder that datomic doesn't actually store keywords internally, they're just the eids of the idents
you’re right. don’t listen to me
yeah. then there’s no semantic benefit other than it reads well
heh. being able to use namespaced keywords with Schema would be interesting nonetheless. I couldn’t make it work.
we’re using them fine
(def User
"A schema for a User entity"
{(s/required-key :user/full-name) Text
(s/optional-key :user/nickname) Text
(s/required-key :user/email) Email
(s/required-key :user/status) (s/enum :status/active
:status/suspended
:status/deleted)
…
@robert-stuttaford: seems like you could generate those from the schema itself, right? DRY and all that
robert-stuttaford: all I know about prismatic schema I’ve learnt from “Clojure Applied” and they didn’t cover that way to build the schema 😛
right i don’t know that way. the way i learned was from the project’s readme
I should do that.. but I don’t have network connection at home, so have been using offline resources as much as possible. I (idiotically) concluded that it wasn’t supported.
😮 no internet at home. gosh.
wow. you’re either very brave or very unlucky. either way, well done for holding up
https://github.com/cape-town-clojure/steel-plains-tcg/blob/deck-builder/src/cljx/sptcg/card_schema.cljx https://github.com/cape-town-clojure/steel-plains-tcg/blob/deck-builder/test/clj/sptcg/tests/card_schema.clj
this was where i learned schema, for a fun-time usergroup we ran for a while
the tests show the actual data that’s being schematised
it wasn’t planned! I signed up for internet a week before we got the keys to the place, but BT didn’t send an engineer until 9 weeks later (today) and he left without connecting everything so it’ll be another 2 weeks I think 😞
you might spot a M:tG nerd in there somewhere -grin-
crikey. my condolences
meh. it’s frustrating, but it helps me getting out of the house while being on sabbatical.
anyone know how to find an entity id’s birthday? i know the id is a composite of the partition it’s in and the timestamp. wondering if it’s possible with bit shifting magic to extract the timestamp component for use with e.g. d/tx-range
@tcrayford: -nudge-
(d/q '[:find (min ?t) . :in $ $h ?e :where
[$h ?e _ _ ?tx]
[?tx :db/txInstant ?t]]
db
(d/history db)
(:db/id (d/entity db [:attr "value"])))
this works, but takes 20ms to do
if i just get the ?tx value directly, it’s 5ms
good enough for me, but i’m hoping for a bitshifting trick
so, thinking about the construction of entity ids, and if I have everything straight in my head, this wouldn't be possible. As far as I recall, the lower 42 bits of an eid are related to the basis-t, which, if you can get to it with bit shifting, still won't give you the txInstant.
ah, but it would give me the t value, which is all i need
aha, okay, then that might work… I'm unsure how it arrives at unique bits for multiple entities in the same transaction though
i’ve just remembered that i asked about this a while back
i understand as much now as i did then about what daniel explained: close to nothing
never did learn the bit math stuff 😊
thank you for having a look i’ll post on the group some time
i’ve asked the twinernet. let’s see