Intersection
Intersection( group, ... )
Returns
When group
is an array, an array of the items that appear in every
provided group
.
When group
is a setref, a setref of the items that appear in every
provided group.
Examples
The following query intersects the SetRef (i.e. set reference) returned
by locating the search term "fire" in the index named
"spells_by_element" with the SetRef returned by locating the search term
"water" in the Index named "spells_by_element". The
Paginate function executes the SetRef
and returns the results of the Intersect
operation in an array of type
Page.
client.query(
q.Paginate(
q.Intersection(
q.Match(q.Index('spells_by_element'), 'fire'),
q.Match(q.Index('spells_by_element'), 'water'),
)
)
)
.then((ret) => console.log(ret))
{ data: [ Ref(id=181388642071085568, collection=Ref(id=spells, collection=Ref(id=collections))) ] }
The following query demonstrates how various arrays are evaluated:
client.query([
q.Intersection(['A', 'B'], ['C', 'D']),
q.Intersection(['A', 'B'], ['B', 'C']),
q.Intersection(['A', 'B', 'C'], ['B', 'C'], ['B', 'C', 'D']),
q.Intersection(['A', 'B', 'C'], ['B', 'B'], ['B']),
])
.then((ret) => console.log(ret))
[ [], [ 'B' ], [ 'B', 'C' ], [ 'B' ] ]
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!