在我的云代码中,我想检索“消息”类中的第一个对象。然后我想从该对象中获取一些信息,将其发送到另一个类,最后从我最初从中提取它的“消息”类中删除该对象。下面是我的代码,但是它不起作用。我应该如何重做这个?
我应该使用与“销毁”方法(例如 collection.remove)不同的方法吗?
Parse.Cloud.afterSave("sendMessage", function(Parse.Message, response) {
var body = null;
var senderName = null;
var senderId = null;
var randUsers = [];
var query = new.Parse.Query(Parse.Message);
query.find({
success: function(results){
body.push(results[1].get("messageBody"));
senderName.push(results[1].get("senderName"));
senderId.push(results[1].get("senderId"));
results[1].destroy({
success: function(results[1]){
//the first object in the class "Messages" was deleted
}, error: function(results[1], error){
//the first object was not deleted
}
});
response.success(getUsers);
}, error: funtion(error){
response.error("Error");
}
});
});
为避免混淆:“getUsers”是任意函数调用。