Return 2 fields from database on drop down query (SOLVED myself again) some forum this

Hi

I have a nice back end function working that when i select a dropdown box it returns the name of the food in the drop down box and returns the value of the protein associated with that food into a textbook $w(“#protein1Text”).text = $w(“#food1Dropdown”).value .(as shown below)

What ii want to do is add a second return value which is the “measurement” field value in the database and return to another text box. $w(“#measurement1Text”).text = $w(“#food1Dropdown”).value2???

can someone help me out with modifying the below code?

many thanks

Fraser

//Backend code
import wixData from ‘wix-data’;

export function populateDropdownfoodtoprotein(collectionName, protein,) {
let allItems = ;
return wixData.query(collectionName)
.ascending(“foodType”)
.find()
.then((results) => {
if (results.totalCount > 0) {
let items = results.items;
items.forEach((item) => {
let oneItem = {
label: item.foodType,
value: item.protein.toString(),
}
allItems.push(oneItem);
})
return allItems;
}
return null ;

}) 

}

//Frontend code

import wixData from ‘wix-data’;
import {populateDropdownfoodtoprotein} from ‘backend/utilitiesModule’;

$w.onReady( async function () {
$w(“#food1Dropdown”).options = await populateDropdownfoodtoprotein(“MyFoods”,“protein”,);
});

export function food1Dropdown_change(event) {
$w(“#protein1Text”).text = $w(“#food1Dropdown”).value
//Second return value (not working)
$w(“#measurement1Text”).text = $w(“#food1Dropdown”).value2???
}

Need to bump this please guys ned help

SOLVED it myself again…

import wixData from ‘wix-data’;

export function food1Dropdown_change(event) {
wixData.query(“MyFoods”)
.ascending(“foodType”)
.eq(“foodType”,$w(‘#food1Dropdown’).value)
.find()
.then( (results) => {
let items = results.items;
let item = items[0];
let measurement = item.measurement;
let protein = item.protein
let fat = item.fat;
let calories = item.calories;
$w(‘#measurement1Text’).text = item.measurement.toString();
$w(‘#protein1Text’).text = item.protein.toString();
$w(‘#fat1Text’).text = item.fat.toString();
$w(‘#calories1Text’).text = item.calories.toString();
console.log(protein,measurement,fat,calories);

} ) 
. **catch** ( (err) => { 

let errorMsg = err;
console.log(errorMsg);

})
}