Fork me on GitHub
#xtdb
<
2021-04-24
>
craftybones04:04:01

Hello, I’ve a simple question on querying vectors

👋 6
craftybones04:04:14

Suppose I have

{:crux.db/id :some-id
 :match/teams [:lakers :celtics]}

craftybones04:04:54

I want all pairs of teams that have played

craftybones04:04:27

{:find [t]
 :where [[m :match/teams t]]}
only returns each individual team

craftybones04:04:57

I got this working with a pull

craftybones04:04:28

{:find [(pull m [:match/teams])]
 :where [[m :match/teams]]}

craftybones04:04:39

But now, I want a count of all those pairs

craftybones04:04:55

The results I want would look something like

#{[[:lakers :celtics] 80] [[:bulls :celtics] 12]....

craftybones04:04:38

Never mind, got it

🦾 3
craftybones04:04:07

'{:find [t1 t2 (count m)]
  :where [[m :match/teams t1]
          [m :match/teams t2]
          [(!= t1 t2)]]}

✔️ 3
craftybones06:04:08

Is there a way to pull a rule out into a var for reuse?

craftybones07:04:06

Ah, I quoted wrong.

refset23:04:24

We've all been there before! Are you constructing rules dynamically?

craftybones11:04:27

Are you from Juxt?

refset12:04:11

Cool, and yes I am indeed - I have been working with Crux since it launched. Please feel free to ask any questions you like and I will do my best to answer :)

craftybones13:04:14

That’s cool. I worked with Hakan briefly and I saw a video of him presenting Crux at a conf.

refset13:04:35

Ah, awesome! Hakan's not active on Slack but he's very much still dedicated to Crux behind the scenes...big plans are afoot 😉

craftybones13:04:06

Yes, I figured Hakan’s not active on Slack.

refset14:04:21

Where were you two working at the time?

craftybones17:04:50

Ah, Thoughtworks

🙂 2
craftybones17:04:02

If you’re talking to him, you can tell him I worked on Krypton with him

👍 2