Display item from reference field in table

Hey,
I have a search system in place and wanted to add displaying the logo.
I tried different ways of making this work (running 2 queries in parallel) but its quite inefficient so I’ve decided to rewrite it merging both into 1 query getting/dislaying all the data.

The issue is how can I would I write the code to fetch the image which is located in another collection. Please see below for more details…

I.e.: Query request is in DATABASE A searching for matching TITLE, but the resultat also has to display an image which is associated via a REFERENCE FIELD (titled: logos) to DATABASE B (titled: logo).

import wixData from “wix-data”;
export function searchmobile_keyPress(event) {
wixData.query(“DATABASE A”)
.contains(“title”, $w(“#searchmobile”).value)
.ascending(“title”)
.limit(5)
.find() // Run the query
.then(res => {
$w(“#molbiletable”).rows = res.items;
$w(“#molbiletable”).expand();
});
}

$w.onReady(async function () {
$w(“#molbiletable”).columns = [
{
“id”: “logo”,
“dataPath”: “logos”, //“logos” is in DATABASE A as a reference field to DATABASE B.
// In DATABASE B, the image column title is “logo”
// How would I write the datapath properly to fetch the image in
the other database??
“label”: “logo”,
“width”:37,
“type”: “image”,
},
{
“id”: “title”, //DATABASE A
“dataPath”: “title”, //DATABASE A
“label”: “title”, //DATABASE A
“width”: 110,
“type”: “string”,
“linkPath”: “homeUrl”, //DATABASE A
},
//column objects
];
});

Thanks for your time!

Tables and galleries can show related items from collections that have reference fields or in situations where you have filtered one dataset by another dataset .
https://support.wix.com/en/article/about-displaying-database-content-in-a-table-or-gallery

Reference fields are used to connect one database collection to another database collection.
Reference fields also provide you with additional options for displaying your data to your users.

  • Format a single table, gallery, or repeater to display information from more than one collection.

  • Create a master-detail page to display items from one collection that relate to another collection.

  • Connect a dropdown list to a reference field so users can save information to your collection.

Note:
You can use galleries, tables, and repeaters when displaying information using reference fields.
https://support.wix.com/en/article/displaying-content-from-multiple-database-collections-using-reference-fields-4034931

See this previous forum post about it too.
https://www.wix.com/corvid/forum/community-discussion/reference-fields-1

Hi Mark,
Reference fields does not populate data automatically into a collection.
You can use two reference fields to display referenced fields in the same table or using repeaters.

Check out this article:
https://support.wix.com/en/article/how-to-use-reference-fields

You could use wixdata hooks and some code to achieve auto data population capabilities.
There is no code examples for this purpose (currently).