I have “multiple reference” fields in my collection and need to show the values on the page.
How can I do that?
I have “multiple reference” fields in my collection and need to show the values on the page.
How can I do that?
So I created my own solution.
Maybe someone next could use it too. … and I am happy for any other creative solution.
That’s mine:
// Reference-Title
export async function getReferenceTitle(refID, dbName) {
const db = await wixData.query(dbName);
let result = [];
for (const id of refID) {
result.push(await getReferenceText(id, db));
}
return result;
}
async function getReferenceText(id, db) {
return (await (db.eq("_id", id).find())).items[0].title;
}
Output is an Array of Title.