I have 2 collections connected by reference field but I can’t get the fields to resolve when I do a wix query and testing the code. All the examples I see have to do with displaying the data on a repeater or table.
Are reference fields only for displaying data on repeaters and tables etc…?
My setup:
Collection1: Primary key ‘email’ (this collection has another single reference field to another collection)
Collection2: Reference field to Collection1, also named ‘email’
return wixData.query("Collection1") .include("Collection2") .find() .then((results) => { results.totalCount console.log(results.items) }) .catch((err) => { let errorMsg = err; console.log("Returned nothing") });
The above code only returns Collection1 data but I’m looking to get Collection1 and the data from Collection2 for that item in Collection1.
Thoughts?
I’ve even tried the reverse, querying Collection2, including Collection1 but same result, only showing data for Collection2.