Expo SQLite 不相信“SQLiteDatabase”类型上存在“事务”

问题描述 投票:0回答:1

我已经遇到这个问题好几个星期了。我已经将

expo-sqlite
安装到我的React Native应用程序中,但如果不不断遇到阻止程序就无法使用它。目前它认为我无法使用这两种方法中的任何一种,尽管在第 1 行声明了
import * as SQLite from "expo-sqlite";

db.transaction
Property 'transaction' does not exist on type 'SQLiteDatabase' 

db = SQLite.openDatabase("tasks.db")
Property 'openDatabase' does not exist on type ...node_modules/expo-sqlite/build/index")'. Did you mean 'openDatabaseSync'?

我认为我可以通过使用如下构造函数来解决 .openDatabase 的问题,但它仍然阻止我调用

db.transaction
:

db;
  constructor(db: SQLite.SQLiteDatabase) {
    this.db = db;
  }

我正在跑步

"expo": "^51.0.0"
"expo-sqlite": "~14.0.3"

我尝试在我的项目中使用新版和旧版的

expo-sqlite
,但没有成功。

react-native sqlite expo
1个回答
0
投票

我认为你必须检查expo-sqlite的新文档,它们更改了所有方法和结构:docs.expo.dev/versions/latest/sdk/sqlite

正如错误所示,您必须使用

openDatabaseSync
并进行交易
withTransactionAsync

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.