我差不多将Objective-C iOS应用程序从Parse.com迁移到自托管的Parse-Server。
但是在进行一些检查时,我注意到我的云功能Parse.Cloud.beforeSave
没有执行,或者至少没有完成所有工作。 为什么?
我想要添加记录的集合(MyCollection)按预期更新,但我有第二个集合(用于簿记)我更新(以保留最后插入的项目的数量)的方式和那个没有完成。
供参考,这是功能代码:
Parse.Cloud.beforeSave
("MyCollection", function(request, response)
{
var queryConfig;
var queryConfig = new Parse.Query("BooKeep");
queryConfig.find({
success: function(resultConf) {
request.object.set("..", resultConf[0].get("...")+1); // This is done as expected.
resultConf[0].set("...", resultConf[0].get("...")+1); // Not done!
request.object.set("...", resultConf[0].get("...")+1); // This is done as expected.
resultConf[0].set("....", resultConf[0].get("...")+1); // Not done!
resultConf[0].save(null,{}); // Not done!
....
response.success();
},
error: function() {
var reptMsg="The BooKeep-UPDATE procedure failed for some reason.";
console.log(reptMsg);
response.error(reptMsg);
}
});
});
在未来的路上进行更多调查,在日志中显示以下内容。至少现在我知道Parse.Cloud.beforeSave正在运行,我以前不太确定。
app[web.1]: info: beforeSave triggered for MyCollection for user Yacb6CzuB9:
app[web.1]: Input: {....}
app[web.1]: Result: {"object":{....}} className=MyCollection, triggerType=beforeSave, user=Yacb6CzuB9
app[web.1]: error: Error generating response. { [Error: unauthorized: master key is required] status: 403, message: 'unauthorized: master key is required' } status=403, message=unauthorized: master key is required
app[web.1]: Error: unauthorized: master key is required
app[web.1]: at promiseEnforceMasterKeyAccess (/app/node_modules/parse-server/lib/middlewares.js:297:17)
app[web.1]: at /app/node_modules/parse-server/lib/PromiseRouter.js:137:22
app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:129:7)
app[web.1]: error: Error generating response. ParseError {
app[web.1]: code: 119,
app[web.1]: message: 'Permission denied for action update on class BooKeep.' } code=119, message=Permission denied for action update on class BooKeep.
app[web.1]: [object Object]
heroku[router]: at=info method=POST path="/parse/classes/BooKeep/JKKmaSzi8H" host=myapp.herokuapp.com request_id=1348711c-25df-4f6e-005b-70632776742d fwd="54.90.99.197" dyno=web.1 connect=0ms service=34ms status=400 bytes=573
2016-11-25T02:47:58.488404+00:00 heroku[router]: at=info method=POST path="/parse/logout" host=myapp.herokuapp.com request_id=dc3b12d1-5f54-11f0-a8cd-54ceca331a80 fwd="106.130.44.123" dyno=web.1 connect=0ms service=23ms status=200 bytes=483
答案 0 :(得分:0)
我已经能够通过转到_SCHEMA集合并更改:
来使其工作rails _4.2.5.1_ new my_new_app
为:
"update": {
"Yacb6CzuB9": true
},
为BooKeep班。
我仍然不明白为什么我必须这样做,因为我不需要每个人都拥有更新权利,但事实是它现在有效。 如果有人可以评论并表明更好的解决方案,我会很高兴。