V1 datalog query - link based on array of ids

I realize xtdb1 has a preferred flat format, but this is where I’m currently at, until I move to v2

I have this data structure within a record

{

“parents”: [
{
“id”: “acct-0hw7zqjmmj”,
“type”: “Identifier”
},

]

I’d like to construct a result that includes the records found for each parent, wherein the linked parent is under an xt/id like “records/acct-0hw7zqjmmj”

I can make basic datalog queries, and have used get-in quite a bit, but I’m struggling with how to reach into the list for each id.

Thanks,

Glen

Hey @tempire

I think you would want something like this, to ‘destructure’ the vector elements into a logic var that you can join against:

[?e :xt/id "foo"]
[?e :parents [?p ...]]
[(get ?p :type) ?type]

Hope that helps,

Jeremy

Yes! Thanks, destructuring was the key.

1 Like