Address Database field type

People, I solved it! I just haven’t got the time to post it here. Here is the thing, the Address Database Field is a JSON, so to save it to your dataset you need to format it as a JSON.

First I created an object as a container to format the address:

function createNewAddressObject(obj) {
 let { address_components } = obj // extract the address_components property of the JSON
 let fullAddress = { // this is the JSON object that is going to be pushed to the database
        city: "",
        location: {
          latitude: obj.geometry.location.lat,
          longitude: obj.geometry.location.lng
        },
        streetAddress: {
          name: "",
          number: ""
        },
        formatted: obj.formatted_address,
        country: "",
        postalCode: "",
        subdivision: ""
    }
 for (const prop in address_components) {
 if (address_components.hasOwnProperty(prop)) {
 const element = address_components[prop];
 if (element.types.includes("administrative_area_level_2")) fullAddress.city = element.short_name
 else if (element.types.includes("route")) fullAddress.streetAddress.name = element.long_name
 else if (element.types.includes("postal_code")) fullAddress.postalCode = element.short_name
 else if (element.types.includes("administrative_area_level_1")) fullAddress.subdivision = element.short_name
 else if (element.types.includes("country")) fullAddress.country = element.short_name
 else if (element.types.includes("street_number")) fullAddress.streetAddress.number = element.short_name
        }
    }
 return fullAddress
}

And then I push the object fullAddress (as newAddressObject that I used as a variable to store the return from the function) to the dataset:

async function createNewCostumerAndInsert() {
 let newCostumer = createNewCostumer(
        $w("#inputNewCostumerName").value,
        $w("#inputNewCostumerCPF").value,
        newAddressObject, // here it is.
        $w("#datePickerNewCostumerBday").value,
        $w("#inputNewCostumerAddComplement").value,
        $w("#inputNewCostumerEmail").value,
        $w('#inputCellphone').value
    )
    newCostumerId = await insertNewCostumer(newCostumer)
 if (newCostumerId) {
        $w('#textAlertNewCostumer').text = "Usuário inserido com sucesso!"
        $w('#textAlertNewCostumer').text.style.color = '#BADA55'
        $w('#textAlertNewCostumer').show()
        $w('#sectionNewCostumer').collapse()
        $w('#sectionNewOrder').expand()
        $w('#inputCostumer').value = newCostumer.name
    } else {
        console.log("Usuário não inserido!")
    }
}