Hi guys i’m building an app using sqlite module , but i’m struggling to understand how can i use it like a function.
i’m opening the database connection in my mainview and creating tabs
var sqlite = require('SQLite');
var db = sqlite.open("Park.sqlite");
db.execute("create table if not exists Settings (Walkthrough VARCHAR(50) NOT NULL, Geolocation VARCHAR(50) NOT NULL, Camera VARCHAR(50) NOT NULL, Notification VARCHAR(50) NOT NULL, Token VARCHAR(50) NOT NULL, PRIMARY KEY (Walkthrough))");
db.execute("create table if not exists Place (address VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY (address))")
db.execute("create table if not exists driverProfileDto (deposit VARCHAR(50) NOT NULL, driverBankingInformationStatus VARCHAR(50) NOT NULL, driverCriminalRecordStatus VARCHAR(50) NOT NULL, driverHomeAddressProofStatus VARCHAR(50) NOT NULL, driverLicenceStatus VARCHAR(50) NOT NULL, driverNationalIdDocStatus VARCHAR(50) NOT NULL, firstName VARCHAR(50) NOT NULL, lastName VARCHAR(50) NOT NULL, login VARCHAR(50) NOT NULL, nbWarning DOUBLE NOT NULL, phoneNumber VARCHAR(50) NOT NULL, points DOUBLE NOT NULL, professionEnum VARCHAR(50) NOT NULL, siretNumber VARCHAR(50) NOT NULL, siretStatus VARCHAR(50) NOT NULL, statusEnum VARCHAR(50) NOT NULL, PRIMARY KEY (deposit))")
then i have a sql service file with some function , so i can call them everywhere in my app.
var sqlite = require('SQLite');
var db = sqlite.open("Park.sqlite");
function SaveSettings(Walkthrough, Geolocation, Camera, Notification, Token){
return new Promise(function(resolve, rejec){
db.execute("insert into Settings values (?, ?, ?, ?, ?)", Walkthrough, Geolocation, Camera, Notification, Token);
resolve()
})
}
function loadSettings() {
return new Promise(function(resolve, reject){
var r = db.query("select * from Settings");
resolve(r)
})
}
module.exports = {
loadSettings: loadSettings,
SaveSettings: SaveSettings
}
But every time i save something , and try to retrieve it , i have an empty value