Fork me on GitHub
#datomic
<
2015-06-10
>
robert-stuttaford05:06:05

@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

robert-stuttaford05:06:21

another thing to note about pull; it doesn’t return :db/id

bhagany05:06:11

yeah, it's understandable, once you think about it. just a little unexpected after using the entity api.

borkdude08:06:10

@robert-stuttaford: I probably can't make it to the hangout, because I'm supposed to work (read: make billable hours) then

borkdude08:06:26

@robert-stuttaford: but if it's going to be recorded, I'm interested in viewing it later

ericfode16:06:11

@robert-stuttaford: your awesome, thankyou.

ericfode16:06:01

When i create a new entity, is there a way to get to it's id from the response?

stig16:06:44

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...

marshall17:06:21

@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

marshall17:06:09

if you’re using tempids from the tempid function, this might also be helpful: http://docs.datomic.com/clojure/#datomic.api/resolve-tempid

tcrayford17:06:39

@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)

robert-stuttaford17:06:38

@stig, @tcrayford, i think namespaced keys index better

robert-stuttaford17:06:52

user/* lives together, etc

robert-stuttaford17:06:10

@stig, you can use ns’d kws with Schema

tcrayford17:06:37

@robert-stuttaford: reminder that datomic doesn't actually store keywords internally, they're just the eids of the idents

robert-stuttaford17:06:56

you’re right. don’t listen to me

robert-stuttaford17:06:34

yeah. then there’s no semantic benefit other than it reads well

stig17:06:49

heh. being able to use namespaced keywords with Schema would be interesting nonetheless. I couldn’t make it work.

robert-stuttaford17:06:59

we’re using them fine

marshall17:06:12

Clojure (keyword ns name) also makes it easier to generate programmatically

robert-stuttaford17:06:22

(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)
…

tcrayford17:06:00

@robert-stuttaford: seems like you could generate those from the schema itself, right? DRY and all that

stig17:06:04

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 😛

stig17:06:30

only the s/defrecord way, which does not work. (As record fields cannot be namespaced.)

robert-stuttaford17:06:58

right simple_smile i don’t know that way. the way i learned was from the project’s readme

stig17:06:16

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.

robert-stuttaford17:06:38

😮 no internet at home. gosh.

stig17:06:44

(I’m in a pub leeching wifi and drinking coffee atm.)

stig17:06:57

Not since mid march, no!

stig17:06:17

The withdrawal is fierce.

robert-stuttaford17:06:01

wow. you’re either very brave or very unlucky. either way, well done for holding up

robert-stuttaford17:06:33

this was where i learned schema, for a fun-time clj usergroup we ran for a while

robert-stuttaford17:06:54

the tests show the actual data that’s being schematised

stig17:06:57

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 😞

robert-stuttaford17:06:15

you might spot a M:tG nerd in there somewhere -grin-

robert-stuttaford17:06:42

crikey. my condolences

stig18:06:54

meh. it’s frustrating, but it helps me getting out of the house while being on sabbatical.

stig18:06:32

Thanks for the help!

robert-stuttaford19:06:51

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

robert-stuttaford19:06:04

(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"])))

robert-stuttaford19:06:49

this works, but takes 20ms to do

robert-stuttaford19:06:46

if i just get the ?tx value directly, it’s 5ms

robert-stuttaford19:06:01

good enough for me, but i’m hoping for a bitshifting trick simple_smile

bhagany19:06:57

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.

robert-stuttaford19:06:31

ah, but it would give me the t value, which is all i need

bhagany19:06:10

aha, okay, then that might work… I'm unsure how it arrives at unique bits for multiple entities in the same transaction though

robert-stuttaford19:06:33

i’ve just remembered that i asked about this a while back

robert-stuttaford19:06:54

i understand as much now as i did then about what daniel explained: close to nothing

robert-stuttaford19:06:08

never did learn the bit math stuff 😊

bhagany19:06:14

hmmm… yeah, I don't think I understand enough to get the info you want

robert-stuttaford19:06:38

thank you for having a look simple_smile i’ll post on the group some time

bhagany19:06:03

sounds good, I'd be interested to see if there's an answer

robert-stuttaford19:06:12

i’ve asked the twinernet. let’s see simple_smile