[SOLVED] How to set a variable’s data

I have an object in the Moralis database with 5 attributes. Two of the attributes need to change from user input.
How could it work to move this value variable into the Moralis set command?

So… I have a Js variable, X
The object tShirt has an attribute of price.
So the variable in JavaScript represents the user entry of price. So this: (“price”, X) of tshirt needs to be (re)set in the database every time we have a new event of user entry.

Forgive for asking this but I cannot find clear documentation on your site docs also on how to simply CHANGE or edit the value of an attribute of an object. I successfully uploaded the values to the database based on your docs, and figured out how to retrieve these values…(thank you) but the explanation on the very simple process of a plain set command is not clear… (and ofc I have watched the videos and read the docs but the all include additional functioning and I am not advanced enough, I guess, to separate!!)

Thank you in Advance.

1 Like

Hey @Ruffin

Take a look at:

Or you can use query to get needed object:

  const query = new Moralis.Query("ItemsForSale");
  query.equalTo("id", "id0001");

  const item = await query.first();
     item.set("status", "sold");
     await item.save();

If you want to change data inyour database periodically you can use Cloud Jobs

Well thank you, I’ll make it happen today!

Made it work! Woohoo thanks

1 Like