Repeater via Code - Fetching from Referenced DB

Hi,

Hope all is well. I can query and display in a repeater the data from the main database (i.e. Collection) but I cannot get it to display data from the referenced database.

import wixData from 'wix-data';

$w.onReady(function () {
   wixData.query("COLLECTION")  
    .descending("date")
    .limit(3)
    .find()
    .then((results) => {
 if (results.totalCount > 0) {
        console.log(results.items);
        $w("#listRepeater").data = results.items;
        
        $w("#listRepeater").onItemReady(($item, itemData, index) => {
        $item("#button2").label = itemData.title;
        $item("#text7").text = itemData.COLLECTION_2.verdate; //COLLECTION_2 is reference database
        });
      } 
    })
    .catch((error) => {
      console.log("Error:", error.message);
    }); 
});

In the main database, I have created a reference-column and explicitly referenced the other database.
Note: it works if I set it up via GUI but I need it to work via Code for more versatility…

Thanks for your time

This could help you…
https://www.wix.com/velo/reference/wix-data/wixdataquery/include

Thanks, exactly what I needed :slight_smile:

Some more informations and an example you can find here…
https://russian-dima.wixsite.com/meinewebsite/how2-include