datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
donavan 2021-02-23T12:43:48.008300Z

Hi, I’m new to Datomic and am looking for some direction in where to learn more about what I’m trying to achieve. I’m trying to ‘mix’ a query and a pull expression in a way that I suspect pull doesn’t allow for. If that is the case is there a more verbose way of achieving what I’m trying to do. I’m trying to do a ‘filter’ at multiple levels of the return result. In other words I’m trying to return things that have at least one sub-thing that itself has an-attr that is "foobar" and only the sub-things that match the sub-thing clause.

'[:find (pull ?thing [:things/field-1 :things/field-etc {:things/sub-things [*]}])
  :in $
  :where
  [?thing :things/sub-things ?sub-things]
  [?sub-things :sub-thing/an-attr "foobar"]]
As far as I understand the pull crawls from ?thing after the query has run so it makes sense in the above query I get all the sub-things and not just the ones that match. But I would really like to constrain the pull expression result somewhat. My real case is more complicated than that and needs to solve the general case. As for solutions I could post process the results of the pull or I could not use pull but then the problem becomes how to construct the tree results using a raw :find clause. If the latter is at all possible (it doesn’t seem like it) is there any resources someone could point me at? The find spec docs seem to me to not support this. A third possible option would be to use nested-queries. Sorry for the vague question! Any advice or pointers would be much appreciated 🙂e

fmnoise 2021-02-23T13:30:21.010700Z

Hi everyone, maybe stupid question, but can I use more recent version of datomic api (eg 1.0.6165) with less recent version of datomic transactor (eg 0.9.6045)? The reasoning behind that is I'd like to try qseq and other added perks without upgrading infrastructure.

fmnoise 2021-02-23T13:31:37.010900Z

Just to mention - I tried and it works, just curious if there are any downsides with such approach

Joe Lane 2021-02-23T14:05:07.012700Z

You can include two pulls in the find clause. You can also do a reverse pull from sub-thing to thing for only matching sub-things.

Joe Lane 2021-02-23T14:05:27.013400Z

I’m sure there are more ways to accomplish this too.

donavan 2021-02-23T14:47:02.013900Z

The reverse pull is a good pointer thanks! The problem is that both of those require post processing to piece the original tree back together because I have an arbitrary amount of these filters to accommodate. What I really need (and I’m pretty sure I understand why it doesn’t work that way) is to be able to unify (I think that’s the right word) the logic variables into the pull expression

Joe Lane 2021-02-23T14:49:52.014100Z

You can't unify lvars in the pull pattern of the pull expression (interesting idea though!)

Joe Lane 2021-02-23T14:52:19.014300Z

You can always issue pulls after the query returns. If your code is in a peer or an ion it's already resident in the db process anyways so those pulls will be just as fast as what d/q does.

donavan 2021-02-23T15:12:29.014500Z

Thanks… that’s a good point about subsequent queries being fast as it’s not on a server somewhere else; I need to let that really sink in properly

Casey 2021-02-23T16:20:41.015400Z

hey folks, is datomic console available with dev-local/cognitect dev tools? Or only for starter/pro/enterprise users?

prnc 2021-02-24T13:28:15.017600Z

@jaret console is not currently available for cloud, is that right?

jaret 2021-02-24T13:28:32.017800Z

Correct.

prnc 2021-02-24T13:28:44.018Z

ok, thanks!

jaret 2021-02-23T17:12:09.015500Z

We always recommend upgrading both (as a member of the Datomic team) 🙂. But while the configuration is not expressly supported all versions are backwards compatible and cross versions work between peer and transactor. If you encounter any particular issue do let me know by shooting an e-mail to <mailto:support@cognitect.com|support@cognitect.com>

jaret 2021-02-23T17:15:15.015700Z

Datomic Console is shipped with Datomic on-prem. Not shipped with cognitect dev tools. Dev tools includes REBL and dev-local.

jaret 2021-02-23T17:15:52.015900Z

If you want to Download Console you can do so from my.datomic: https://my.datomic.com/downloads/console

fmnoise 2021-02-23T17:31:25.016200Z

thanks @jaret

jaret 2021-02-23T17:32:46.016400Z

The caveat to this is there are some extremely old versions that would have some issues with local storage and potentially the introduction of versions spanning schema changes (i.e. the addition of tuples) may encounter some issues.

Casey 2021-02-23T19:27:54.017200Z

That's great, thanks for the tip.