0

我有一个js函数

export const cleanUp = async () => {
    await User.destroy({ where: {} });
};

我正在尝试await User.destroy({ where: {} })使用以下插入一行

recast.parse(`await ${module}.destroy({ where: {} });`);

但我坚持。因为esprimaUnexpected Identifier需要一个异步声明。我还能如何实现这一目标?

4

1 回答 1

0

esprima 声称“完全支持 ECMAScript 2016(ECMA-262 第 7 版)”,而“等待”初始定义在“ECMAScript 2017 (ECMA-262)”中

我认为这可能是问题所在。

http://esprima.org/ (特色段落)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#Specifications

于 2019-04-09T18:26:53.027 回答