wix data update

In this code

import wixData from ‘wix-data’;

export function updateButton_click(event) {
//Add your code for this event here:
let toUpdate = {
here I define the fields to be updated
};

update(“#StockData”, toUpdate)

I get the error report in the six site editor

“update is not defined”

I can use save()

Any Help will be welcome

Read the Docs wix-data - Velo API Reference - Wix.com. It will solve it for you

I fear you may have missed my point - or I don’t understand the documentation - if so can you point me to the solution?

My issue is that my attempts to write an update() statement when editing my code the EDITOR flags a ‘red dot’ with the explanation that ‘update does not defined’

Yes
and the doc says not update but wixData.update as the way to execute a update. Try change that and it will work

Hello,

Andreas is pointing you to the right direction, your code will look something like this:

import wixData from 'wix-data';
export function updateButton_click(event) {  
 let toUpdate = {
      //update data
 };      
 
 wixData.update("#StockData", toUpdate) 
 .then( (results) => {
	let item = results; //see item below
  })
  .catch( (err) => {
	let errorMsg = err;
  });
 
}

Goodluck!
Majd

Thank-you Majd,

A good step forward!

I have used update() as suggested - should “#StockData” be the name of the Dataset or
the Collection? Either way the update does not change the collection - or report an error!

Whereas if I call

$w(“#StockData”).save(toUpdate);

the Collection is updated.

help!