I need to find the ID of myCollection. I have the value of other field (Id_sqlSel) of this collection. So i wrote this backend function:
export function findId(myCollection, Id_sqlSel)
{
wixData.query(myCollection)
.eq(“id_sql”, Id_sqlSel)
.find()
.then ( results => {
let items = results.items;
let item = items[0];
let idCollection= item._id;
return idCollection;
})
}
I need to get the idCollection when I call the function from this page function:
export function buttonPruebaFuncion_click(event) {
let IdSel = parseInt($w(“#idInput”).value, 10);
findId(“TempPeople”, IdSel)
.then( function (findId) {
console.log(findId);
$w(“#inputResultados”).value = findId;
});
}
… but I only get an undefined value.
Can any of you explain what I’m doing wrong?
Thank you,
Arturo