Using the Wix Data Query [SOLVED]

Hi

I have a Database with 2 columns: ‘Country’ & ‘Code’

I have a Dropdown list connected to the Country Column of the Database

Whenever a Value is selected in my dropdown, I would like the input value in $w(“#clientphone”).value to show the ‘Code’ from the Database

export function country_change(event, $w) {
    wixData.query('ArrivalFormCountry')
    .eq('title', $w("#country").value)
    .find()
    .then( (results) => {
    console.log(results.items);
 let code = results.code;
    $w("#clientphone").value = code; 
  } );}

Can anyone point out where I am wrong above ?

I am getting the following string on my dev console
{“_id”:“dee6076e-3b04-4ffb-b549-6a48169fba81”,“_owner”:“33aa2185-3bf6-4b55-8034-834d8eb40644”,“_createdDate”:“2018-06-01T16:41:50.171Z”,“_updatedDate”:“2018-06-12T07:42:24.956Z”,“title”:“BELGIUM”,“code”:“+235”}

Solved it

If anyone like me finds themselves in a similar situation, this is what you need

 
export function country_change(event, $w) {
    wixData.query('ArrivalFormCountry')
    .eq('title', $w("#country").value)
    .find()
    .then( (results) => {
    console.log(results.items);
 let Item = results.items[0]; //get the items from the database
    $w("#clientphone").value = Item.code; //Item. followed by your field key in your database
  } );}