Changing field value in the DB with a cloud function called from frontend

Hello, I’m trying just for testing to write on the database on a collection where the CLP permission is read only for public using a simple testing cloud function that I call from frontend.

This is the frontend code

const params =  { name: "London" };
const nameChange = await"testNameChange", params);

This is the cloud code

Moralis.Cloud.define("testNameChange", async (request) => {
  const userAddress = request.user.get('ethAddress');
  const query = new Moralis.Query("Cities");
  query.equalTo("User", userAddress, 'i');
  const cityItem = await query.first();
  if (cityItem) {
  requireUser: true

Console log seems working on the variables (it retrieves the correct row) but nothing is written in the database.

Where could be the issue?

Thank you

You have to use .save(null, {useMasterKey: true})

1 Like

Yes I’ve tried and it worked, Thank you a lot

1 Like