function saveProperties() {
$w('#buttonSubmit').disable();
let user = wixUsers.currentUser; //<---here you get the USER GOOD!
let userId = user.id; //<---here you get the USER-ID GOOD!
let myQuery = wixData.query("Properties") //<--- here you get all data from your PROPERTIES-DB, GOOD!
myQuery.eq("_owner", userId).find()
.then((res)=>{console.log("RESULTS: ", res);
//not so good!
/*
let toUpdate = {
let toUpdate = {
"industry2": $w("#checkboxGroup1").value,
"title": $w("#input2").value,
"agentEmail": $w("#input3").value,
"mapLocation": $w("#input36").value,
"businessWebsite": $w("#input35").value,
"facebook": $w("#input33").value,
"instagramLink": $w("#input34").value,
"hoursOfOperation": $w("#input37").value,
"description": $w("#richTextBox1").value,
"familyPic1": familyPhoto1,
"familyPic2": familyPhoto2,
"amenities": $w("#selectionTags1").value,
"_userId": userId
};
*/
// using instead....(direct way)
let items = res.items; console.log("ITEMS: ", items);
if(items.length>0){console.log("Length > 0 !");
let firstItem = items[0];
firstItem.title = $w("#input2").value;
firstItem.agentEmail = $w("#input3").value;
firstItem._userId = userId
firstItem.industry2 = $w("#checkboxGroup1").value;
firstItem.mapLocation = $w("#input36").value;
firstItem.businessWebsite = $w("#input35").value
firstItem.facebook = $w("#input33").value
firstItem.instagramLink = $w("#input34").value
firstItem.hoursOfOperation= $w("#input37").value;
firstItem.description = $w("#richTextBox1").value
firstItem.familyPic1 = familyPhoto1; // where does this come from ?
firstItem.familyPic2 = familyPhoto2; // where does this come from ?
firstItem.amenities = $w("#selectionTags1").value;
//--------------------------------------------------------------------------
wixData.update("Properties", firstItem)
}
});
Where do these values come from ?
firstItem.familyPic1 = familyPhoto1; // where does this come from ?
firstItem.familyPic2 = familyPhoto2; // where does this come from ?
Where do you declare → familyPhoto1 / familyPhoto2 ???
How do I get the file upload fields to prefill with what is already in the database?
Which are your → file upload fields
How does it look like inside your database?
Just you know the structure of your own database.