Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Alter a object variable inside cloud functions

I am trying to alter a object variable after query in cloud functions, but before sending it to my app, but not sure how to do so! Here is what I am trying to do:

Parse.Cloud.define("getUserData", async(request) => {

    // Getting the users data
    const userQuery = new Parse.Query("UserData");
    userQuery.equalTo("userId", request.params.userId);
    const userData = await userQuery.first();

    // Getting the groups
    const groupQuery = new Parse.Query("GroupMembers");
    groupQuery.equalTo("userId", request.params.userId);
    groupQuery.include('pointerObject'); // including the pointer object 
    const groups = await groupQuery.find();

    const allGroups = [];

    for (let i = 0; i < groups.length; ++i) {
        var thisGroup = groups[i].get("pointerObject");

        thisGroup.isFavorite = true;

        allGroups.push(thisGroup);
    }

    var returnObject = {
        "playerData": userData,
        "playerGroups": allGroups
    }

    const jsonString = JSON.stringify(returnObject);

    return jsonString;
});

It is "thisGroup.isFavorite" i am trying to set to true, but when receiving the jsonString, it is still set to false? How do I alter a variable in cloud functions?

Any help is appreciated and thanks in advance :-)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try with:

thisGroup.set('isFavorite', true);
await thisGroup.save();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!