Fork me on GitHub
#datomic
<
2017-07-12
>
val_waeselynck06:07:37

cjmurphy: answered!

cjmurphy03:07:40

If anyone can help or point me to where the documentation is. Thanks..

pesterhazy06:07:14

@cjmurphy I think you need to do first twice in read-account

pesterhazy06:07:59

d/q returns a sequence of tuples. You want the first element of the first tuple I think

cjmurphy06:07:25

@pesterhazy Interesting - so it really is just supposed to be just a number?? I've been thinking of using (d/entity db bank-acct-id) - to really put an entity there. I can't test either approach (`ffirst` or d/entity) right now as there seem to be other problems I need to sort out. Thanks and I'll be back..

pesterhazy06:07:53

an entity id is just a long, yes

cjmurphy06:07:48

And d/entity will work as well because of upserting, but is kind of pointless??

pesterhazy06:07:49

you can also find a unique identifier for your entity and use that in a lookup ref like so: [:my.entity/name "CJ Murphy"]

rauh06:07:10

@cjmurphy I agree with Peter, or you can use .... :find ?a . (notice the trailing dot)

rauh06:07:23

That'll return a single value

cjmurphy06:07:26

Make it a scalar

pesterhazy06:07:33

*Paulus 🙂

rauh06:07:45

Ooopsie, sorry Paulus. 🙂

pesterhazy06:07:20

not sure what you mean about d/entity

cjmurphy06:07:58

That's a function you pass an eid and it returns the data.

cjmurphy06:07:36

I went for that idea when I thought just putting a number there was wrong. But you guys have corrected me now. thanks.

pesterhazy06:07:00

my rule of thumb is not to expose entity ids to the outside

pesterhazy06:07:27

but it's fine to use them within your code

cjmurphy06:07:35

So put a db/id there in preference to an eid?

cjmurphy06:07:00

Definitely within the code.

pesterhazy06:07:10

:db/id is the entity id

cjmurphy06:07:00

Oh right. So when I pull on [:db/id] I'm doing something senseless.

isaac10:07:26

Does Datomic database functions support multiple arity? (fn [arg1] [arg1 arg2])

mike_ananev14:07:59

Hi! We are doing PoC of global data registry, where we trying to specify the shape of our data from various sources using clojure.spec. We considering to use Datomic as spec storage. Is it a good idea to store a clojure.spec expressions as Strings in Datomic? Spec is used in application level, where we do ETL, validation, transformatio, sample generation.

tomc18:07:17

Is it possible to change the owner of an entity referenced via an isComponent attribute in a single transaction?

tomc18:07:33

Ah, I should specify that the original owner is deleted in that same transaction.

tomc18:07:22

Example: in a tree, replace a node with one of its children, deleting the replaced node and any of its children that are not the one that replaced it.

favila19:07:59

@tomc [:db.fn/retractEntity the-parent] will retract the is-component children. So you can do it only if you don't use retractEntity

tomc19:07:34

So if I explicitly retract all attributes of the parent it'll have the same effect, except I'll be able to move the child to another parent?

favila20:07:39

You can always move the child; the question is whether there will be any assertions left on the child.

favila20:07:59

Yes you can do what you propose. But it sounds like maybe your attribute should not be is-component?

tomc20:07:51

In my case I think isComponent is the right choice, and using explicit attr retractions on the parent will probably solve my problem.

favila20:07:19

is-component attrs have a (not-enforced) invariant that the :v of every datom with that attribute is not the :v of any other datom

favila20:07:17

IOW, the "child" entity (value of the is-component attr) is not reachable except from a single parent and that one attribute.

tomc20:07:33

Understood, but if I make that change in a single transaction, that invariant is not violated, correct? This seems like something I could write a transactor function to handle...

favila21:07:09

@tomc true, it is not. it's just strange for the lifetime of the child to outlive the parent. If you keep the invariant you will be fine though.

tomc21:07:49

Ok, thank you for the help.