Fork me on GitHub
#datomic
<
2017-01-17
>
eoliphant00:01:19

hey has anyone looked at datomic as a chat backend? We’re looking at some chat features taht need to be pretty tigthly integrated with an in-house app. I was thinking that streaming the tx log would make it effectively ‘reactive'

favila01:01:17

@eoliphant datomic doesn't scale writes well and has some practical datom limits. Not saying its impossible but it's probably not a good fit

eoliphant01:01:27

hmm ok good to know

eoliphant01:01:51

it’s not large scale, but will consider that

favila01:01:15

yeah at small scale nothing matters, it's all fine

favila01:01:27

easy-to-use tx queue is a nice feature

pseud11:01:18

So I just downloaded datomic-free & tried to install the console into the extracted datomic directory. Launching the console, I get Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class. Is it no longer possible to run the console with the free edition ?

mitchelkuijpers14:01:56

@pseud I don't think that was ever possible because the free version does not have a transactor, which is the thing you have to connect the console too

jaret14:01:15

@pseud @mitchelkuijpers You should be able to use console with free and you do have a transactor with free. You have to download console separately and install it into the datomic install directory. I just tested and got the same error so I am thinking we might have broken something with standalone console. I am currently investigating to figure out what exactly broke

jaret14:01:48

For free you run a free protocol transactor with:

bin/transactor config/samples/free-transactor-template.properties

mitchelkuijpers14:01:31

@jaret Did not know that, sorry

jaret14:01:36

It can definitely be confusing because of the free protocol, but as long as you aren't using an in MEM db you can connect console to it

jaret14:01:52

or should I say, you should be able to connect console to it 😉

pseud14:01:23

Yea, that was my understanding from reading the guides too. I'm guessing the problem now stems from some compiled code which console depends on being different between free & pro bundles. I wonder if console shouldn't just be bundled in with free these days, given its availability to free users also ? Why the extra hoops to jump ? I'm already committing to learning a new query language, use a proprietary closed-source, one-off database - seems like that's enough commitment. I know that comes off as a bit mean, but understand that leadership adopts a technology, and other employees (such as I) are forced to come to terms with it. Jumping through hoops to approach feature-parity (in terms of dev tooling) only breeds resentment.

jaret14:01:25

I understand where you are coming from. I would suggest that you register for Starter edition(its free for registered users). Its identical to PRO in all respects and comes bundled with console. I think that would get you going and working.

Matt Butler15:01:09

Is there a simple way to clear the object cache for benchmarking sake?

Matt Butler15:01:16

And on an unrelated note is is possible to limit a many cardinality ref relationship in datalog, so that the where clause only applies to the newest?

[?entity :likes ?items]
  [?items :attr val]
Does the limit expression in the pull API guarantee any kind of order newest/oldest first? If so, can this be manipulated?

jfntn17:01:09

For integration purposes we're looking at using squuids as unique identities for all our entities (about 20 now), but I'm not fully grasping the respective trade-offs of reusing a global :db/uuid attribute vs. a per-entity :<entity>/uuid attribute. Concerned about impact on performance and indexing I guess?

seantempesta17:01:33

Is there a way to get all datoms associated with an entity? I’m trying to send a filtered version of my database down to a datascript client. My schema has a clear separation of data at the :organization entity level (all datoms pointing from there can be sent to the client).

lellis17:01:53

@seantempesta Dont know if is your case, take a look at touch method? http://docs.datomic.com/entities.html

seantempesta17:01:19

@lellis: Interesting. So (d/entity (d/db conn) 17592186047972) and then traverse that for a list of :db/id, calling (d/datoms (d/db conn) :eavt %) on each entity id?

rauh17:01:11

@seantempesta I usually just do pull and then send that data to the client, datascript will also be fine with nested maps, given a proper schema. So pretty simple overall

seantempesta17:01:00

@rauh: Sorry. Not sure if I follow. Do you have the relevant code snippet?

rauh17:01:02

But if you want more magic, then I agree with lellis: Walk the entity along and send that map.

rauh17:01:45

(d/pull eid [:post/id :post/title {:post/comments [:comment/id]}] [:post/id post-id]) e.g.

rauh17:01:15

but you have to manually opt in for every entity, no magic involved. Which might be what you want in case you store secrets in the db in the future

lellis17:01:32

@seantempesta no, i mean

(d/touch (d/entity (d/db conn) 17592186047972)) 
will initialize all entity attributes.

rauh17:01:45

Of course you can also just do * for the pull and also do recursion in the pattern

seantempesta17:01:33

Don’t I need to get the individual datoms to transact on the datascript side?

rauh17:01:48

Nope, nested maps is just fine.

rauh17:01:00

Given the right schema of course.

seantempesta17:01:00

Okay. I’ll try that. Thanks!

seantempesta18:01:53

@rauh: Okay, so transit wasn’t able to encode the entity map. java.lang.Exception: Not supported: class datomic.query.EntityMap. Am I missing a step?

rauh18:01:33

@seantempesta A pull shouldn't return an entity

seantempesta18:01:28

Oh right. I was still using the d/entity

jdkealy19:01:46

how would i do something like the following: I have a permission that might be tied to a user and a user has an email, or a permission is "pending" and would have an email associated directly. https://gist.github.com/jdkealy/50b1e64f27f5973054b0ce99c313de95

jdkealy19:01:11

Trying (or ) gives me the error Assert failed: All clauses in 'or' must use same set of vars, had [#{?email ?user ?e} #{?email ?user}] (apply = uvs)

favila20:01:35

I think you meant to put [?e :permission/user ?user] outside the or? @jdkealy

jdkealy20:01:55

that still doesn't seem to work either... same error (d/q '[:find ?e ?email :in $ ?ent :where [?e :permission/ent ?ent] [?e :permission/user ?user] (or [?user :user/email ?email] [?e :permission/email ?email])] _db id)

jdkealy20:01:57

also i think even if that did work, none of the permission/email would return because they don't have a permission/user @favila

favila20:01:41

Don't you mean [?user :permission/email ?email]? that's what you had before

jdkealy20:01:48

sorry, it's... either [?permission :permission/email ?email] or [?user :user/email ?email]

jdkealy20:01:31

but i was just calling ?permission ?e just to make things confusing 🙂

favila20:01:50

[:find ?e ?email
       :in $ ?ent
       :where
       [?perm :permission/ent ?ent]
       (or-join [?perm ?email]
         [?perm :permission/email ?email]
         (and
           [?perm :permission/user ?user]
           [?user :user/email ?email]))]

favila20:01:03

Is that what you mean?

jdkealy20:01:57

hmm maybe... lemme try

jdkealy20:01:03

looks right

favila20:01:48

the critical thing is or-join, resolves the problem that was giving you an error

favila20:01:51

by default or tries to unify all its vars with the surroundings, but you had different vars in each half of the or, so it could not do that

favila20:01:50

or-join restricts the unification with what is outside the clause to only the vars mentioned, essentially allowing ?user to act as a kind of private variable only unified within its clause

jdkealy21:01:45

awesome that works thanks @favila

zane21:01:54

Is there a reason why or-join clauses only allow you to pass in a single source?

tmorten21:01:24

Hello all! I have an interesting problem...I'm using Pedestal/Datomic combination and when I use retractEntity function to retract an entity all of my other data clears on the site until (I believe) I run a pull at a very top level entity. I get a new "db" for every request so I'm not sure why it actually takes "pull" on a top level entity to get the data to come back...

sova-soars-the-sora22:01:19

@tmorten hmm... not knowing much about pedestal, how does it merge in new data when you get it?

tmorten22:01:51

@sova: I have an interceptor wrapper per request that injects a new "(d/db conn)" into my request chain. So essentially, every page refresh I would get a new datomic db...what is odd is that, I experience this at the REPL too... I retract the entity...get a new db per (d/db conn) and begin to query the db...which I am left with ONLY entity IDs and no other associations. Doesn't come back until I (d/pull ... a top level entity). For what it is worth, I am retracting an entity that was linked to that entity...

sova-soars-the-sora22:01:02

Hmm.. Would you mind posting the lines you are using to retract? I'm interested in getting to the root of your issue... will read a bit about pedestal

sova-soars-the-sora22:01:02

@tmorten ... follow-up question, So when you say "top level entity" what do you mean?

sova-soars-the-sora22:01:28

because in my use with Datomic all the entities just kinda live in a big ... entity ocean

tmorten22:01:58

Yeah, sorry. By top level I mean it has association to entity I am retracting. In a one many assoc

sova-soars-the-sora23:01:20

looks good to me.. let me check it against my typical code...

sova-soars-the-sora23:01:46

Hmm so for my retracts

sova-soars-the-sora23:01:48

they look like this

sova-soars-the-sora23:01:06

(defn remove-blurb [bid]
  (let [blurb-info (get-blurb-by-bid bid)
        b-title (:title (first blurb-info))
        b-content (:content (first blurb-info))
        b-author (:publisher (first (get-publisher-email bid)))]
  (d/transact conn [[:db/retract bid :blurb/title b-title]
                    [:db/retract bid :blurb/content b-content]
                    [:db/retract bid :author/email b-author]])))

sova-soars-the-sora23:01:43

So maybe you are losing attributes because you're not specifying on which attribute+val it should remove. Do you know more about the entity you want to retract? If you do, you could supply the :werds/ident and the "value" @tmorten

tmorten23:01:10

Perhaps I need to remove the entity ID from the association also? Does datomic automatically remove that ID from the list if you use the retractEntity FN?