Hi all, I'm currently working on how to use joins...
# community-help
s
Hi all, I'm currently working on how to use joins for this use case : productinfo_[locale](alias) pricebook(alias) sku product_id Where locale can be any one of : en_CA, fr_CA, en_US ..... The join is supposed to be based on the equivalence of values in sku and product_id fields in their respective collections. However, I'm not sure how I can set a reference in the product_id field of the only pricebook collection to the sku field in multiple productinfo collections.
k
cc @Harpreet Sangar
h
@Shiva Dixith You can create reference field in every productinfo_[locale] collection.
s
It's actually one to many from productinfo_[locale] to pricebook
Would reference field in productinfo_[locale] work in this scenario?
h
It's actually one to many from productinfo_[locale] to pricebook
I don't follow. Can you share an example?
You mean to say multiple collections like
productinfo_en_CA
,
productinfo_fr_CA
, etc.?
s
Well... What I meant is that one sku in productinfo_[locale] will have multiple entries with the same product_id in pricebook
h
I'm assuming something like:
Copy code
productinfo_en_CA: [
                       {sku: 1, product_id: a},
                       {sku: 1, product_id: a},
                       {sku: 2, product_id: b}
                   ]
s
In productinfo_en_CA it is sku only In pricebook the same field is named product_id
Both these fields have same values
It is just that a sku in productinfo will have multiple matching docs in pricebook ( list price, sale price etc)
h
Is it not possible for you to have individual collections for each price type?
s
I could do that but still need to fetch them all to compare them and determine which price to show.
h
Then only way this would work is you'll have to create n reference fields in the pricebook collection for each locale.