非常奇怪的问题 - 我可以创建一个新对象,但是我无法返回新创建的对象。
我可以返回object.id,object.get(“name”),但不是整个对象。我在iPhone 4s 7.1.2上使用XCode 6.1.1进行部署。
有什么想法吗?
Parse.Cloud.define("createCityChatRoom", function(request,response){
var CityChat = Parse.Object.extend(constants.kBPCityChatRoomClassKey);
var cityChat = new CityChat();
cityChat.set(constants.kBPGroupChatRoomEndDate, request.params.endDate);
cityChat.set(constants.kBPCityChatRoomCreatingUser, request.user);
cityChat.set(constants.KBPCityChatRoomLocation, request.params.location);
cityChat.set(constants.kBPCityChatRoomCityName, request.params.cityName);
if(request.params.chatName){
cityChat.set(constants.kBPCityChatRoomChatName, request.params.chatName)
}
else{
var chatName = request.params.cityName+" tonight";
cityChat.set(constants.kBPCityChatRoomChatName, chatName);
}
cityChat.save().then(function(results){
console.log(results.id); // returns objectid
console.log(results.get("name")); // returns name
response.success(results);
}, function(error) {
console.log(error);
});
});
答案 0 :(得分:0)
您可以尝试以下语法:
cityChat.save(null, {
success: function(result) {
console.log(result.id); // returns objectid
console.log(result.get("name")); // returns name
response.success(result);
// or
response.success();
}, function(error) {
console.log(error);
}
});