Basic question regarding field reference

Hi,
I have a dynamic item page which connects to collection A.
In collection A I have a field reference to collection B.
In my code I use:
const currentItem = $w(“#collectionA”).getCurrentItem();
What should I do in order to use the referenced data from collection B (from performance prescriptive, what is the recommended option) ?

Thanks a lot,
J.D.

#database #reference #join #performance

Typically when you’re referencing, you want to get ahold of the _id of the referenced item. This way you can just do a query straight into Collection B, with a .eq(“_id”, “currentItem._id”) then the first results (the only result since its an exact match) is all there as results.items[0]

@ken-yeh , thank you.