Fork me on GitHub
#datomic
<
2016-06-30
>
jdkealy01:06:33

I finally just got the transactor working. Thanks for your help 🙂

len08:06:16

Hi all, I have this existing system that uses a trad ORM with the party model. Party is a base entity that has children of either an Org or a Person. Whats the way to approach such a thing with datomic ?

danielstockton09:06:20

@len divide the attributes into :party/attributes, :org/attributes and :person/attributes

len09:06:28

and then just join them together as needed, seems so simple 🙂

danielstockton09:06:43

yep, you just get things which have one or more of the attributes you're interested in, you don't have to think in terms of models and inheritance like a trad ORM

len09:06:46

I am going through that switch now yip, very elegant

zentrope17:06:08

If you’ve got many :refs associated to an attribute, how do you remove one of them from the list?

marshall17:06:42

@zentrope: simply transact a retraction [:db/retract entity-id :my-ref-atrib current-value]

zentrope17:06:15

Ah, okay. ;) Hm.

marshall17:06:58

Based on your description i’m assuming it is a cardinality many attribute

marshall17:06:36

that ^ form will retract only the "current-value” ref, but leave the others

zentrope17:06:40

Yes, I have something like :product/orders :many. I just want to retract one of those orders.

marshall17:06:19

so, that retraction will retract the reference from your entity to the order.

marshall17:06:30

if you want to retract the whole order entity you’ll need to handle that separately

zentrope17:06:41

What’s the current-value in your example?

zentrope17:06:49

(No, don’t want to retract the actual order.)

marshall17:06:01

it would be the entity id of the order that is referred to by the reference

marshall17:06:19

so if :product/orders has 3 values, call them A, B, C

marshall17:06:27

and you want to retract the reference to B

marshall17:06:36

you’d put the entity ID of B in for current-value

zentrope17:06:03

And a reference to :product/orders’ entity as entity-id.

marshall17:06:47

you might also want to have a look at http://docs.datomic.com/transactions.html#built-in-transaction-functions specifically the retractEntity function - if you ever want to remove the order itself and all references to it

zentrope17:06:51

[::db/retract [:product/id “asda”] :product/orders [:order/id “asa”]] <— that sort of thing (pseudocode)?

zentrope17:06:27

Okay, I think I got it.

zentrope17:06:00

Retract the attribute/value from the entity.

marshall17:06:13

the pseudocode you have there says something along the lines of “i have an entity with :product/id “asda” and it has a bunch of references through the attribute :product/orders. one of those references is to an entity that has the attribute :order/id “asa” and I want to remove that reference from the “asda” entity"

zentrope17:06:47

Ok. Thanks.

zentrope17:06:14

Hm. Can you actually use [:ns/attr “an-id”] in db/retract?

zentrope17:06:54

I’m getting an “invalid lookup ref”.

zentrope17:06:20

[:db/retract 277076930200665 :spec/controls [:product/id "a82f5914d899edc259c96303e89133299f14b635”]]

marshall17:06:28

I believe retract requires a value there, not an identity.

marshall17:06:05

You can query for the value first then issue the retraction

marshall17:06:43

You should be ablr to use a lookup ref in the e position however

zentrope17:06:03

Hm. I’m getting an “invalid list form” even with proper eids. Must be something else.

zentrope17:06:20

Oh, I see. I’m just adding the retract/asserts as a value to an attribute in a map, rather than just concatting them on to the TX itself.

zentrope17:06:59

@marshall: Using [:product/id “foo”] inside a [:db/retract] works fine.

marshall17:06:27

Ah. Good deal.

zentrope17:06:49

Yeah. Makes sense that it would.

jdkealy21:06:39

when i try to compile my app, it starts a peer connection and i go over my peer limit. Do people typically have a def like this (def conn (d/connect uri)) or do you set the connection as an atom var on start ?

Ben Kamphaus21:06:49

@jdkealy: the component (Stuart Sierra’s lib) example here is the typical way I see people approach this (also some other good advice in the blog post in general): http://www.rkn.io/2014/12/16/datomic-antipatterns-eager-conn/

ddellacosta22:06:18

datomic newbie here—is there any way for me to introspect into the schema itself?

ddellacosta22:06:04

...assuming that's a meaningful question

ddellacosta22:06:10

@bkamphaus: just the sort of thing I was looking for—thanks so much!

jdkealy22:06:15

im confused about what peers might be connected. is there some way to reset them all ?

Ben Kamphaus22:06:29

Killing the process or calling release for a peer is sufficient, transactor will log all ips connected.