Below is my JS code that is supposed to delete a pointer reference to a 'Game' object which is stored in an array under the key 'games' in the 'team' object. Fetching works and all the 'success' logs below get called meaning that the .remove and .save functions get called, but for some reason, this does not do anything and the pointers still exist in the arrays after the execution of this code. What am I doing wrong?
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);
}
});