Update a specific object [Javascript]

Hi, I am trying to retrieve a specific row from a table, make a few changes and update the changes. Looking for a solution in Javascript. The code I have currently is:


var dataQuery = new Backendless.DataQuery();
dataQuery.condition = "ID = 'S1234567A'";
var accounts = Backendless.Persistence.of(Accounts).find(dataQuery);

Lets say i want to change the fields Name and Email and update them, how would I go about doing that, I’ve been looking through everywhere and cannot find a solution, please help! Thanks.

Hi John,
Please, carefully read our JS SDK doc. Especially chapter with updating data.
In your case, it will look like

var dataQuery = new Backendless.DataQuery();
dataQuery.condition = "ID = 'S1234567A'";
var accounts = Backendless.Persistence.of(Accounts).find(dataQuery);


var account = accounts.data[0];
account['Name'] = 'New Name';
Backendless.Persistence.of(Accounts).save(account);

Regards, Ilya

Thanks for the solution, I have got it to work.

Just wondering, the link you posted shows how to Create and then Delete what was created. It din’t show how to Find and then delete?

Yes, there is not exactly the same example as in your case.
But there is an example of how to update a recently saved object in the last code snippet.
Anyway, I glad that I helped you.
Have fun.