在Parse Cloud Code(Javascript)中从数组中删除对象

时间:2015-08-25 05:34:06

标签: javascript parse-platform cloud-code

下面是我的JS代码,它应该删除对'Game'对象的指针引用,该对象存储在'team'对象中关键'games'下的数组中。获取工作和下面的所有“成功”日志被调用意味着.remove和.save函数被调用,但由于某种原因,这没有做任何事情,并且指针在执行此代码后仍然存在于数组中。 我做错了什么?

var queryTeam = request.object.get("awayTeamID");

queryTeam.fetch({
    success: function(awayTeam){

        console.log("Success in Fetching awayTeam Object. Destroying Now.");

        awayTeam.remove(awayTeam.get("games"), request.object);
        awayTeam.save();

        var queryTeam = request.object.get("homeTeamID");

        queryTeam.fetch({
            success: function(homeTeam){

                console.log("Success in Fetching homeTeam Object. Destroying Now.");


                homeTeam.remove(homeTeam.get("games"), request.object);
                homeTeam.save();
            },
            error: function(homeTeam, error){
                console.error("Error removing game from homeTeam array! " + error.code + ": " + error.message);
            }
        });
    },
    error: function(myObject, error){
        console.error("Error removing game from awayTeam array! " + error.code + ": " + error.message);
    }

});

0 个答案:

没有答案