What I want to do is create multiple tables for my react-native android app but it keeps returning an unknown error each time the code execute(but it works fine with creating a single table).
This is the code I have
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");
});
});
}
How can I make it create multiple tables