Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Objective.js中的异步$formatDatabaseJson_Javascript_Model_Async Await_Objection.js - Fatal编程技术网

Javascript Objective.js中的异步$formatDatabaseJson

Javascript Objective.js中的异步$formatDatabaseJson,javascript,model,async-await,objection.js,Javascript,Model,Async Await,Objection.js,我需要等待$formatDatabaseJson中的函数。我正在检查文档(),似乎不可能。有没有办法手动完成 class Person extends Model { async $formatDatabaseJson(json) { // Call the super class's implementation. json = await super.$formatDatabaseJson(json) // await function here retu

我需要等待$formatDatabaseJson中的函数。我正在检查文档(),似乎不可能。有没有办法手动完成

class Person extends Model {
  async $formatDatabaseJson(json) {
    // Call the super class's implementation.
    json = await super.$formatDatabaseJson(json)
    // await function here
    return json
  }
}

$formatDatabaseJson
是同步的,不能用于调用异步代码
$beforeInsert
$beforeUpdate
$afterGet
钩子是异步的,可以根据您的用例使用。

不是解决方案,但最后我使用了$beforeInsert,因为它支持异步执行