我想在云代码中同步更新解析对象并检查更新是否成功?然后运行一些逻辑并返回用户的结果。parse 使用 node SDK 解析云代码,示例是异步的。
这是解析文档示例,但异步。
你只需要使用异步/等待:
Parse.Cloud.define('myFunction', async req => {
const GameScore = Parse.Object.extend("GameScore");
const gameScore = new GameScore();
gameScore.set("score", 1337);
gameScore.set("playerName", "Sean Plott");
gameScore.set("cheatMode", false);
gameScore.set("skills", ["pwnage", "flying"]);
await gameScore.save();
// Now let's update it with some new data. In this case, only cheatMode and score
// will get sent to the cloud. playerName hasn't changed.
gameScore.set("cheatMode", true);
gameScore.set("score", 1338);
await gameScore.save();
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句