Saving Object Number field

UPDATE:
Got it! forgot to save! Here is the working code:

const Conts= Moralis.Object.extend("Conts");
              const query = new Moralis.Query(Conts);
              const toUpdate = await query.get(cont.id);
              await toUpdate.increment("votes");
              toUpdate.save();

Hi guys,
I am trying to save an Object with a number field β€œvotes”, anyhow, I am facing strange behaviour. In the first place, when creating the object, the votes column is not created, So I added it manually. Now when trying to increment it, the field shows as incremented when the object comes back in the console, but it will not be in the database:

Code
//Code for Object creation
const newCont = new Moralis.Object("Contributions");
      newCont.set("ipfs", ipfs);
      newCont.set("hash", hash);
      newCont.set("file", MoralisFile);
      newCont.set("owner", currentUser);
      newCont.set("name", name);
      newCont.set("description", description);
      newCont.set("votes", 0);
      newCont.set("voters", []);
      await newCont.save();
//Code for update
  const query = new Moralis.Query("Memes");
              const toUpdate = await query.get(meme.id);
              console.log(toUpdate);
              await toUpdate.increment("votes");

What am I doing wrong? :thinking:

i think this code line should also have await. :slight_smile:

Carlos Z

1 Like