Fork me on GitHub

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 $
  [?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

Joe Lane14:02:07

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 Lane14:02:27

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


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 Lane14:02:52

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

Joe Lane14:02:19

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.


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


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.


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


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:[email protected]|[email protected]>


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.


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


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


If you want to Download Console you can do so from my.datomic:


That's great, thanks for the tip.


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


ok, thanks!