Please check the Wix API Reference as it would tell you there that you need to include all fields and not just a select few of them.
https://www.wix.com/corvid/reference/wix-data.html#update
update( )
Updates an item in a collection.
…
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.
,
The last two examples will be of best use to you here.
Examples
Update an item with a specified ID in a collection
import wixData from 'wix-data';
// ...
let toUpdate = {
"_id": "00001",
"title": "Mr.",
"first_name": "John",
"last_name": "Doe"
};
wixData.update("myCollection", toUpdate)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );
/* item is:
*
* {
* "_id": "00001",
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
* "_createdDate": "2017-05-24T12:33:18.938Z",
* "_updatedDate": "2017-05-24T12:33:18.938Z",
* "title": "Mr.",
* "first_name": "John",
* "last_name": "Doe"
* }
*/
Update an item in a collection using data options
import wixData from 'wix-data';
// ...
let toUpdate = {
"_id": "00001",
"title": "Mr.",
"first_name": "John",
"last_name": "Doe"
};
let options = {
"suppressAuth": true,
"suppressHooks": true
};
wixData.update("myCollection", toUpdate, options)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );
/* item is:
*
* {
* "_id": "00001",
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
* "_createdDate": "2017-05-24T12:33:18.938Z",
* "_updatedDate": "2017-05-24T12:33:18.938Z",
* "title": "Mr.",
* "first_name": "John",
* "last_name": "Doe"
* }
*/
Get an item in a collection and update it
This example demonstrates the get() function followed by the update() function. When updating an item in a collection, all existing item properties must be passed to the update() function. If only the changed property is passed, the values of the other item properties will be lost. To ensure all item properties are included in the update, perform a get() on the item, change a property, and then update() the item.
import wixData from 'wix-data';
/* existing item:
*
* {
* "_id": "00001",
* "title": "Mr.",
* "first_name": "John",
* "last_name": "Doe"
* }
*
*/
wixData.get("myCollection", "00001")
.then( (item) => {
item.last_name = "Smith"; // updated last name
wixData.update("myCollection", item);
} )
.catch( (err) => {
let errorMsg = err;
} );
/* updated item:
*
* {
* "_id": "00001",
* "title": "Mr.",
* "first_name": "John",
* "last_name": "Smith"
* }
*
*/
Query an item in a collection and update it
This example demonstrates the query() function followed by the update() function. When updating an item in a collection, all existing item properties must be passed to the update() function. If only the changed property is passed, the values of the other item properties will be lost. To ensure all item properties are included in the update, perform a query() on the item, change a property, and then update() the item.
import wixData from 'wix-data';
/* existing item:
*
* {
* "_id": "00001",
* "title": "Mr.",
* "first_name": "John",
* "last_name": "Doe"
* }
*
*/
wixData.query("myCollection")
.eq("first_name", "John")
.eq("last_name", "Doe")
.find()
.then( (results) => {
if(results.items.length > 0) {
let item = results.items[0];
item.last_name = "Smith"; // updated last name
wixData.update("myCollection", item);
} else {
// handle case where no matching items found
}
} )
.catch( (err) => {
let errorMsg = err;
} );
/* updated item:
*
* {
* "_id": "00001",
* "title": "Mr.",
* "first_name": "John",
* "last_name": "Smith"
* }
*
*/