Fork me on GitHub
#crux
<
2021-01-18
>
Dan Abrams20:01:33

I'm trying to refactor the code in "Web Development with Clojure, 3rd Edition" to use Crux instead of Postgres. I'm running into one area where I don't fully know what to do. In the book, the example application is a simple social network, and I'm trying to represent a "boost," a data type that represents a "retweet" or similar. I have two questions around this, the first is a sanity check--I'm representing a boost as a separate entity from a post, like so:

{ :post-id post
  :booster user }
Does this seem like a reasonable way to do it?

👍 3
Dan Abrams20:01:00

I'm struggling further when I try to query a list of posts and left outer join a list of users who "boosted" it. It's fairly simple to inner join it, but we might have a post that has no boosts, and I don't know how to do that query effectively.

jarohen22:01:38

Hey @UTECZMYPJ 👋 I'd recommend trying the EQL projection functionality - have a look at https://opencrux.com/reference/queries.html#eql-projection

jarohen22:01:17

essentially, you split your query into two - the :where to narrow down to your list of posts, then the eql/project to declare what data you'd like about those posts

Aleksander Rendtslev00:01:47

I noticed that eql/project comes with an Alpha warning in the docs. Would you recommend using it at this point or is it still very likely to change?

jarohen09:01:44

@U01DH13SK8E good question - we're happy with how it's turned out, so it's looking like moving to a stable API in the next release or two, in its current form. It's getting a couple of additions to bring it closer to the EQL spec (unions, recursive queries) as well as a few custom parameters. The one breaking change is that we're considering renaming it to pull so that queries are more portable between Crux, Datomic and Datascript

Aleksander Rendtslev09:01:25

Okay, that sounds great. And that would be an easy change to implement regardless. Sounds like that would be the way to go. And yay, for making the api more comparable!

🙂 1
Dan Abrams20:01:06

Thank you in advance for your help.