Fork me on GitHub
#datomic
<
2016-09-21
>
kurt-yagram07:09:24

@bahulneel @ethangracer Thanks! This is really cool... For now, since it's inside another pull (I need one-level deep attributes of one of the attributes of a pull), I'm defining which attributes are used :

(d/q '[:find [?an ...]
       :in $
       :where
       [?e :whatever/value ?m]
       [?m ?a _]
       [?a :db/ident ?an]]
    (d/db conn))
and I use this one inside a pull like:
...
whatever-attributes (d/q '[:find [?an ...]...) ;; query above
attributes [:whatever/id
            :whatever/value whatever-attributes]
find `[[(~'pull ~'?e ~attributes) ...]]
...
(d/q `{~':find ~find
       ~':in ~in
       ~':where ~where})

ethangracer13:09:00

@kurt-yagram awesome! take a look at the following tutorial to see how you can parameterize your queries, so that you don’t have to inject them using syntax quotes, etc. which is both time consuming and hard to get right http://www.learndatalogtoday.org/chapter/3

kurt-yagram13:09:23

@ethangracer yeah, I didn't like all the syntax-quote stuff... didn't think of parameterizing it though, stupid me. I only parametrized single values so far. Thx!

ethangracer13:09:25

@kurt-yagram I just discovered the full power of datomic’s parameterization too. It’s pretty fantastic.

kurt-yagram14:09:52

from datomic docs:

(d/q '[:find ?p (pull ?tx [:db/txInstant]) ?added
       :in $ ?userid
       :where [?u :user/purchase ?p ?tx ?added]
              [?u :user/id ?userid]]
     (d/history db) userid)
However, when I try something like that, I get IllegalStateException Can't pull from history datomic.pull/pull* (pull.clj:294) So... when did that change?

marshall14:09:29

@kurt-yagram Where in the docs is that example? I’ll fix it.

marshall14:09:05

## Changed in 0.9.5344 * Improvement: Throw error when datomic.api/pull is passed a history db.

ethangracer14:09:57

@marshall why was it decided that pull couldn’t be used on a history db?

marshall14:09:43

@ethangracer it never would have worked, the improvement was to throw when tried. The semantics of pull are current-schema-dependent

ethangracer14:09:26

@marshall Interesting. Is there any documentation / talks about why that is? I’m curious to understand more

marshall14:09:04

@kurt-yagram thanks. i’ll fix that

kurt-yagram15:09:44

just a quick question: if an entity is retracted, and that entity is a component of other entities, it's retracted from the parent-entities as well. Also, all components of the retracted entity are retracted - I never used retract so often in 1 sentence. However, can I add the retracted entity again? What will happen? Will it restore the old state, like, add previously retracted components? Will it be added as a component to the previously parent, where it was a component of? (Does this actually make any sense?)

robert-stuttaford15:09:34

that all depends what you mean by 'add the retracted entity again' 🙂

bahulneel15:09:50

Does anyone know if it's possible to know if a variable is already bound in a rule?

jgdavey15:09:51

I’ve done a “reverse” transaction before, and that works well for this kind of thing

robert-stuttaford15:09:02

@kurt-yagram: remember that it's all just datoms. [this-e :value ":-)"] [this-e :relationship that-e] [that-e :value " 😎 "]. if you restore these datoms, you restore those entities and their relationships

robert-stuttaford15:09:29

Datomic becomes crystal clear when you understand this fact, imho

jfntn18:09:09

Has anyone used datomic as an http-session store for something like ring-session?

jfntn18:09:44

I’m thinking the history would be really useful for analytics and the peer cache should mitigate performance concerns, but I don’t know if there are reasons why this would be a bad idea…?

marshall18:09:06

I have heard of several people considering Datomic as a session store

marshall18:09:15

I don’t have much in the way of specific details

marshall18:09:09

One question I might consider is the total volume of sessions you expect to need to handle over time

marshall18:09:50

since you can’t delete data from Datomic

marshall18:09:18

if you only want to keep sessions around for a few days (or however long), you’d have to address how to handle that

marshall18:09:25

evidently a couple folks have indeed thought about it at least: https://github.com/gfZeng/datomic-session-store https://github.com/hozumi/datomic-session Caveat - I have no personal knowledge of these repos and their value/quality/live-ness/etc 🙂

jfntn18:09:27

interesting!

jfntn18:09:08

Maybe having a session/key that doesn’t track history could be a way to invalidate them while keeping the data around?

marshall18:09:49

You could definitely use noHistory. of course then you don’t get the benefit of having history for audit/metrics/debugging/etc

marshall18:09:59

but unless you have a really busy site, the overall data volume will likely not be prohibitive even if you keep everything

marshall18:09:08

that is the Datomic Way after all 😉

Chris Bidler21:09:31

silly question - is Cognitect aware that has an invalid SSL cert on it (cert is for , Safari on (i|mac)OS 10 at least carps about the hostname mismatch)?

csm21:09:23

also, chrome and curl both complain about that cert, but https just forwards to http