How would you structure the schema? I think I got ...
# community-help
d
How would you structure the schema? I think I got this a little backwards. So what I'm trying to do is have a Variants collection that contains my different variants (product skus). Then I have multiple collections from different Shopify stores where these variants are for sale. Not all Variant SKUs exists in all stores. I want to then get the Variants that exists on the current store. So if the user is on
/en-us
then I want to get all the variants that has matching field
sku
from the
Shopify US
collection. Currently I set it up so Variants have this field
Copy code
{
  name: "shopify_us",
  type: "string",
  reference: "Shopify US.sku",
  optional: true,
},
and then I can query my Variants collections like
Copy code
const storeCollection = 'Shopify US';

...

query: {
  q: '*',
  filter_by: `$${storeCollection}(sku:=${props.sku})`,
  per_page: 1,
},
So far so good. But how do I do that filter when I'm not looking for a particular SKU? Say it's
q: 'lounge chair'
now I still want to get all documents from
Variants
where this
shopify_us
field exists. But I don't know the SKU, or I have the SKU as a field on the Variants document, but I don't think I can self-reference from the current document to the filter like `filter_by: `$${storeCollection}(sku:=${self.sku})`` and I don't think that it's possible to query for null or undefined values. So I must be thinking in paths not suited for this. What would be a better approach?