将解析服务器 2.x 升级到 3.x 与旧代码库兼容

Upgrade parse server 2.x to 3.x is the old code base compatible

我们可以将解析服务器 2.8 更新到 3.x。我们的云代码库使用 backbone 样式的响应回调。这与新的 3.x 更新兼容吗?具体 3.1.2.

我们的代码库使用旧式成功、错误回调,我们是否必须根据 changelong

将所有代码迁移到 promises 或异步等待

https://github.com/parse-community/parse-server/blob/master/CHANGELOG.md

与其中一位回购贡献者直接对话后,必须迁移代码,请参阅 migration guide

从 Parse-server 版本 3 及更高版本开始,Parse Server 使用 Parse JS SDK 版本 2.0+。

因此,您需要将所有 backbone 样式更改为:

  • 承诺
  • Async/Await 函数

例如:

new Parse.Query('your_class_name')
.find({
 success:function(result){}
});

应更改为:

new Parse.Query('your_class_name')
.find()
.then((results)=>{})
.catch((error)=>{})

如果你在异步函数中,那么你可以这样做:

const asyncFunc = async() => {

  try {
    const results = await new Parse.Query('your_class_name').find();
    // do something with the results here.

  } catch (error) {
    // do something with the error
  }

}