[SOLVED] Can not update user attribute

I run this code from my own nodejs server, I passed the address of user as a parameter.
The problem is I can not update reward and email field of User table but I can update any field of Gotchi table.

Moralis.Cloud.define("resetReward", async (request) => {
	const User = Moralis.Object.extend("User");
	const query = new Moralis.Query(User);
  	query.equalTo("ethAddress", request.params.address);
  	const user = await query.first({useMasterKey: true});
    if (user) {
    	user.set("reward", 1);
      	user.set("email", "[email protected]");
      	user.save();
  		const Gotchi = Moralis.Object.extend("Gotchi");
  		const query2 = new Moralis.Query(Gotchi);
  		query2.equalTo("tokenId", 1);
      	const gotchi = await query2.first();
      	gotchi.set("level", 1);
      	gotchi.save();
      return {"status": "Success"};
    } else {
      return {"status": "Error", "msg": "Cannot found user"};
    }
});

you could try user.save(null, { useMasterKey: true }), no idea if it will work

2 Likes

thank you dude. it’s working.