在云函数中修改对象变量



我试图在云函数查询后改变对象变量,但在将其发送到我的应用程序之前,但不确定如何做到这一点!下面是我要做的:

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"我试图设置为真,但当接收到jsonString时,它仍然设置为假?如何更改云函数中的变量?

任何帮助都是感激和提前感谢:-)

Try with:

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

相关内容

  • 没有找到相关文章