I am trying to create Database for my react native app using expo's SQLite and followed its documentation for it but I think Database isn't initializing.
Documentation: expo-sqlite
App.js:
console.log("init () above");
init()
.then(() => {
console.log("DATABASE INITIALIZED");
})
.catch(() => {
console.log("FAILED DATABSE INITIALIZATION", err);
});
console.log("init () below");
//Nothing logs in console
Console:
init () above
init () below
places: Array []
I created the promise as init() which returns an error if it fails and when it resolves it logs a success message DATABASE INITIALIZED. But I am not getting any output.
helper/db:
import * as SQLite from "expo-sqlite";
const db = SQLite.openDatabase("places.db");
export const init = () => {
const promiseDB = new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(
"CREATE TABLE PLACES IF NOT EXISTS places (id INTEGER PRIMARY KEY NOT NULL, title TEXT NOT NULL, imageUri TEXT NOT NULL, address TEXT NOT NULL, lat REAL NOT NULL, lng REAL NOT NULL)"
);
[],
() => {
resolve();
},
(_, err) => {
reject(err);
};
});
});
return promiseDB;
};
I am not getting any errors and also not the success message in the console. I don't know what's the issue and what I am doing wrong?