Hello,
I am having a bad time with CloudFunctions and updating an item that exists in the database.
I am following this example of querying an object based on an attribute and then setting a different attribute, followed by a save. The field i want to update is called ‘theUpdateValue’ and is a boolean which is initially False. I can see this column in the database dashboard.
Example taken from - Moralis: Updating Objects
Moralis.Cloud.define("updateMyObject", async (request) => {
const AirdropQualifier = Moralis.Object.extend("MyObject");
const logger = Moralis.Cloud.getLogger();
const query = new Moralis.Query(AirdropQualifier);
try{
const address = request.params.address;
query.equalTo("address", address);
const queryResult = await query.first();
logger.info(address); <------ THIS IS CORRECT AND LOGS TO CONSOLE
logger.info(queryResult.id); <-------- THIS IS CORRECT AND LOGS TO CONSOLE
queryResult.set("theUpdateValue", request.params.value);
return queryResult.save();
} catch(err){
return err
}
});
I am getting. What am i doing wrong here?
2022-03-23T10:44:33.827Z - Error: Object not found.
When is use logger.info(JSON.stringify(result)) i can see the correct result in the dashboard as per the following post.