更改云函数中的对象变量

Alter a object variable inside cloud functions

我想在云函数中查询后更改对象变量,但在将其发送到我的应用程序之前,但不确定如何操作!这是我正在尝试做的事情:

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;
});

是“thisGroup.isFavorite”我想设置为true,但是收到jsonString的时候还是设置为false?如何更改云函数中的变量?

感谢任何帮助并提前致谢:-)

试试:

thisGroup.set('isFavorite', true);
await thisGroup.save();