Parse cloud returning empty ParseObject ( empty estimatedData) if changing value

for(var i=0; i < results.length; i++){
var currSkill = results[i];
currSkill.set(“name”,‘test’);
}
}
return results;

If I change this parseObject in the cloud code the results array return ParseObject of type Skill but empty but if I don’t change hence if I don’t write

currSkill.set(“name”,‘test’);

it return with values… Anyidea why and how I can fix it ?

Can you please share the whole code of the cloud code function?

we ended up doing something else but anyway here’s what it looked like

Parse.Cloud.define(‘updateObjectWithoutSave’, async function(req,res){
var skillQuery = new Parse.Query(‘Skill’);
try{
var results = await skillQuery.find();
for(var i=0; i < results.length; i++){
var currSkill = results[i];
currSkill.set(“name”,‘test’);
}
}
return results;
}catch(e){
throw new Error(e)
}

});

I was able to reproduce the problem and I also checked the open source code. Since the object is dirty, its attributes are not sent. You’d need to save it before returning. Or you can use this code:

Parse.Cloud.define('updateObjectWithoutSave', async function() {
  const skillQuery = new Parse.Query('Skill');

  const results = await skillQuery.find();

  return results.map(currSkill => {
    currSkill.set('name', 'test');
    return currSkill._toFullJSON();
  });
});
1 Like

Thank you Davi! This community is just awesome :heart_eyes:

1 Like