我想要做的是为我的 react-native android 应用程序创建多个表,但每次代码执行时它都会返回一个未知错误(但它可以很好地创建一个表)。
这是我的代码
initDB() {
let db;
return new Promise((resolve) => {
console.log("Plugin integrity check ...");
SQLite.echoTest()
.then(() => {
console.log("Integrity check passed ...");
console.log("Opening database ...");
SQLite.openDatabase(
database_name,
database_version,
database_displayname,
database_size
)
.then(DB => {
db = DB;
console.log("Database OPEN");
db.executeSql('SELECT 1 FROM Feed LIMIT 1').then(() => {
console.log("Database is ready ... executing query ...");
}).catch((error) =>{
console.log("Received error: ", error);
console.log("Database not yet ready ... populating data");
db.transaction((tx) => {
tx.executeSql('CREATE TABLE IF NOT EXISTS Feed (feedId, feedName, feedDesc, feedPrice)');
tx.executeSql('CREATE TABLE IF NOT EXISTS Comment (commentId, feedId, commentDesc)');
tx.executeSql('CREATE TABLE IF NOT EXISTS User (userId, userName, userPass, userAdmin)');
}).then(() => {
console.log("Tables created successfully");
}).catch(error => {
console.log(error);
});
});
resolve(db);
})
.catch(error => {
console.log(error);
});
})
.catch(error => {
console.log("echoTest failed - plugin not functional");
});
});
}
我怎样才能让它创建多个表