gpt4 book ai didi

javascript - Parse.com 云代码 : Can't save data browser object

转载 作者:行者123 更新时间:2023-11-29 22:01:09 25 4
gpt4 key购买 nike

我正在使用以下代码从用户好友列表中删除 currentUser

result.set("DateUserList", datelistArr); 

这有效,但是:

result.save();

不起作用 - 检查数据浏览器时我没有看到更改。

Parse.Cloud.define("hello", function(request, response) {

response.success("Hello world!");});

Parse.Cloud.define("DeleteUserFromDateList", function (request, response) {

var userToDelete = String(request.params.currentUser);
var user = String(request.params.dateid);

var query = new Parse.Query("User");
query.equalTo("fbId", user);

query.first(
{
success: function (result)
{
var datelistArr = result.get("DateUserList");
for(j = 0 ; j < datelistArr.length;j++)
{
if (datelistArr[j] == userToDelete)
{
console.log("found a match");
datelistArr.splice(j);
console.log("deleted");
break;
}
}

console.log(datelistArr);
result.set("DateUserList", datelistArr);

result.save().then(function (savedObj)
{
response.success(userToDelete + "is deleted from " + user + " friend list");

},
function (saveError)
{

response.error("Unable to create this object");

});

},
error: function () {
response.error("Error occured on User deletion");
}
});

});

最佳答案

保存是异步的,您不会在调用 response.success() 之前等待它完成。而是使用此 promise 语法在保存结果时调用成功。

result.save().then(function(obj) {
response.success(....

}, function(err) {
...

});

关于javascript - Parse.com 云代码 : Can't save data browser object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23698105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com