我正在使用objectId
提供云功能,我想执行多项操作。
这是我的云代码:
Parse.Cloud.define("setStartPoint", function(request, response) {
var deliveryId = request.params.deliveryId;
var Delivery = Parse.Object.extend("Delivery");
var deliveryQuery = new Parse.Query(Delivery);
deliveryQuery.get(deliveryId, {
success: function(delivery) {
console.log("Delivery found: " + delivery.id );
},
error: function(object, error) {
console.log("Delivery NOT found: " + error.message );
response.error();
}
});
// The problem starts here
// I need the results of the query here:
console.log(del.get("name"));
});
有没有办法从get()
?
答案 0 :(得分:0)
这是一个使用承诺的更新版本,可以帮助您朝着正确的方向前进 - 让我知道它是否需要更清晰。
Parse.Cloud.define("setStartPoint", function(request, response) {
var deliveryId = request.params.deliveryId;
var Delivery = Parse.Object.extend("Delivery");
var deliveryQuery = new Parse.Query(Delivery);
deliveryQuery.get(deliveryId)
.then(function(delivery){
console.log("Delivery found: " + delivery.id );
response.success(delivery) //return delivery to calling function after async .get()
}, function(err){
console.log("Delivery NOT found: " + err.message );
response.error();
});
});