wixData.update for selected fields

I am looking for a way for wixData.update to modify selected fields in the Collection without deleting every other field on the same row.

The collection has 10 fields and I am I am using this code to insert, display or update the Collection data for 3 specific fields ‘q11’, ‘q12’ and ‘q13’.

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady(()=> {
 if(wixUsers.currentUser.loggedIn){
        wixData.query("PreWorkSet1")
        .eq('_owner', wixUsers.currentUser.id)
        .find()
        .then((results)=>{
 let items=results.items;
            $w('#textBoxQ11').value=items[0].q11;
            $w('#textBoxQ12').value=items[0].q12;
            $w('#textBoxQ13').value=items[0].q13;
        })
    }
})

export function button1_click(event) {
 let userId = wixUsers.currentUser.id;
    wixData.query("PreWorkSet1")
    .eq("_owner", userId)
    .find()
    .then((results) => {
 let items = results.items[0];
 if (results.items.length === 0){
 let toInsertQOnes = {
 "q11":   $w('#textBoxQ11').value,
 "q12":   $w('#textBoxQ12').value,
 "q13":   $w('#textBoxQ13').value
            };
            wixData.insert("PreWorkSet1",toInsertQOnes)
            .then((results2) => {
 let items2 = results2;
                wixLocation.to("/preworkset1-p2");
            })
            .catch((err) => {
 let errorMsg=err;
            })
        }
 else {
 let currentItemId = items._id;
 let toUpdateQOnes = {
 "_id": currentItemId,
 "q11":   $w('#textBoxQ11').value,
 "q12":   $w('#textBoxQ12').value,
 "q13":   $w('#textBoxQ13').value
            };
            wixData.update("PreWorkSet1", toUpdateQOnes)
            .then((results3) => {
 let items3 = results3;
                wixLocation.to("/preworkset1-p2");
            })
        }
    }) 
}

The diplay part within the onReady works perfectly.

I am having problems with the part within ‘button1_click’.

Any time a user submits the data, the three specific fields are inserted or updated perfectly, however, the other 7 fields in the same row get deleted.

How do I get the button1_click to update the 3 fields without deleting the other 7?

https://www.wix.com/corvid/reference/wix-data.html#update
The update() function compares the _id property of the specified item with the _id property values of the items in the specified collection. If an item in the collection has that _id value, update replaced the item’s property values with the ones in the specified item. If the existing item had properties with values and those properties were not included in the specified item, the values in those properties are lost. The item’s _updatedDate property is also updated to the current date.

You might be better using getCurrentItem and then setFieldValue or setFieldValues.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#getCurrentItem
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValue
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValues

Thank you @givemeawhisky I tried the setFieldValues, but I found it still deleted the other fields.

What I was trying to achieve turned out to be too complicated for my skills level, so I simplified the over user-experience to avoid too much coding.

I appreciate your help.

givemeawhisky, thanks for this - I’ve tried using getCurrentItem & setFieldValue instead of update() function, but just can’t get it to work - I’ve put a link to it here https://www.wix.com/corvid/forum/community-discussion/async-update-vs-getcurrentitem-setfieldvalue please could you comment?