If I have an `inventory` collection which has a `p...
# community-help
t
If I have an
inventory
collection which has a
product_id
field that references an
id
in a
products
collection, is there a way to formulate a join query that searches
products
and returns only the items that are referenced in the
inventory
collection?
h
Yes, you can specify
Copy code
collection: products
q: query
filter_by: $inventory(id: *)
t
Thanks!
Just curious, can you please break down what this query does? I'm wondering why we do
$inventory(id: *)
and not
$inventory(productId: *)
h
id: *
filter matches all the documents of a collection. No other field has an equivalent mechanism. So with
$inventory(id: *)
we do an "inner join" of the
product
documents that matched the query and all of the
inventory
documents.
t
Thank you