如何更新在云代码中同步的解析对象然后检查它是否成功?

how to update parse Object synchronized in cloud code then check if it was successfull?

我想在云代码中同步更新解析对象并检查更新是否成功?然后 运行 一些逻辑和 return 用户结果。 parse 在parse云代码中使用node SDK,其示例是异步的。

here 是解析文档示例,但是是异步的。

你只需要使用 async/await:

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();
});