使用Node.js实现Cassandra中的异步等待(Async Await)

3
我想使用 Async Await 函数来执行我在 cql 中编写的查询语句。
client.execute('select * from users).then(res => {
    console.log('hello user');
}, err => {
    console.log(err);
});

有人能告诉我将这个查询转换为Async Await函数的确切翻译吗?

1个回答

4

我已经解决了,但是我不会删除这篇文章,因为它可能对某些人有所帮助。

app.get('/', async(req,res) => {
    const res1 = await client.execute('select * from users);
    var user = res1.rows[0];
    console.log('successfull');
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接