sto sviluppando un applicazione con React-native e volevo create un database per memorizzare alcuni data per non richiederli Continuamente al server , ma to avendo Problemi .
这些是错误消息:
ERROR TypeError: 0, _expoSqlite.openDatabase is not a function (it is undefined), js engine: hermes
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
我有一个处理数据的视图模型,我希望数据库与视图模型交互,为其提供所需的数据,这是我的 StorageManager :
import { openDatabase } from 'expo-sqlite';
class StorageManager {
constructor() {
this.db = openDatabase("mostriDB");
}
initializeDatabase() {
this.db.transaction(tx, error => {
tx.executeSql(
`CREATE TABLE IF NOT EXISTS users (
uid INTEGER PRIMARY KEY,
picture TEXT,
pversion INTEGER
)`
);
error = (e) => {onerror(e)
this.db.transaction(transaction,error);
};
});
}
如果数据库不存在,则应创建数据库;如果之前尚未完成,则应创建表。不幸的是,当应用程序与存储交互时,它给我带来了问题
sqlite 最近将“openDatabase”命令更改为以下内容:
打开数据库异步()
打开数据库同步()