Join
Join( source, detail )
Description
The Join
function finds all index tuples from the source
SetRef and
uses the source
's values to be retrieved from the detail
index
terms.
The run time of To work around this, you may specify a larger query timeout via the driver that you are using. |
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
SetRef |
The source SetRef for the join operation. |
|
IndexRef or Lambda function |
The IndexRef to join with the |
Examples
The index form is useful when the documents in the source_set
match
the terms
in an index. Join
returns documents from an Index
(specified by detail
) that match the terms from source
.
client.query(
q.Paginate(
q.Join(
q.Match(
q.Index('spellbooks_by_owner'),
q.Ref(q.Collection('characters'), '181388642114077184')
),
q.Index('spells_by_spellbook'),
)
)
)
.then((ret) => console.log(ret))
{ data:
[ Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections))),
Ref(id=181388642071085568, collection=Ref(id=spells, collection=Ref(id=collections))) ] }
The Lambda form requires the Lambda function to be pure. i.e. it may not make any reads or writes.
client.query(
q.Paginate(
q.Join(
q.Match(
q.Index('spellbooks_by_owner'),
q.Ref(q.Collection('characters'), '181388642114077184'),
),
q.Lambda(
'spellbook',
q.Match(q.Index('spells_by_spellbook'), q.Var('spellbook')),
)
)
)
)
.then((ret) => console.log(ret))
{ data:
[ Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections))),
Ref(id=181388642071085568, collection=Ref(id=spells, collection=Ref(id=collections))) ] }
The events view of Join
contains events for joined sets as the join
filtered by when the join document was live in the source set.
client.query(
q.Paginate(
q.Events(
q.Join(
q.Match(
q.Index('spellbooks_by_owner'),
q.Ref(q.Collection('characters'), '181388642114077184'),
),
q.Index('spells_by_spellbook'),
)
)
)
)
.then((ret) => console.log(ret))
{ data:
[ { ts: 1527095186458101,
action: 'add',
document:
Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections))) },
{ ts: 1527095186458101,
action: 'add',
document:
Ref(id=181388642071085568, collection=Ref(id=spells, collection=Ref(id=collections))) } ] }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!