gpt4 book ai didi

expo - 从 expo sqlite 查询得到响应

转载 作者:行者123 更新时间:2023-12-05 05:10:48 27 4
gpt4 key购买 nike

根据 Expo documentation with SQLite 我会这样查询:

tx.executeSql(sqlStatement, arguments, success, error)

我是这样执行的:

db.transaction(tx => {
tx.executeSql('SELECT * FROM dr_report_properties WHERE orderId = (?)', [this.state.orderId]);
},
error => {
alert(error);
},
(tx, results) => {
console.log(results);
}
);

我的问题是如何获得回复?以上返回未定义。然后我尝试(不期望它能工作,但只是为了踢球)

console.log(tx);

这确实给出了一个 console.log

(tx, results) => {
console.log('I got data');
}
)

根据文档:

ResultSet objects are returned through second parameter of the success callback for the tx.executeSql() method on a Transaction (see above). They have the following form:
{
insertId,
rowsAffected,
rows: {
length,
item(),
_array,
},
}

我希望结果是这个对象。对我做错了什么有什么想法吗?

最佳答案

上面的问题是我在执行之后调用它实际上是在与那个相同的方法中。

结果应该像这样进入回调:

db.transaction(
tx => {
tx.executeSql('select * from my_table', [], (trans, result) => {
console.log(trans, result)
});
}
);

感谢世博会团队的@charliecruzan!

关于expo - 从 expo sqlite 查询得到响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56247557/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com