0

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 :-)

1 Answer 1

1

Try with:

thisGroup.set('isFavorite', true);
await thisGroup.save();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.