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!