I'm trying to return the results of the query but I always get undefined. I'm not sure what I'm doing wrong here. I'm using react native with sqlite storage plugin.
let SQLite = require('react-native-sqlite-storage')
let db = SQLite.openDatabase({name : "db.v1.33", createFromLocation : "~db.db"});
let sqlResults;
export function GetQuestions(sqlType,questionsCount) {
let sqlQuestions = `SELECT * FROM Questions WHERE Type IN (${sqlType}) ORDER BY RANDOM() LIMIT ${questionsCount}`
db.transaction((tx) => {
tx.executeSql(sqlQuestions, [], (tx, results) => {
sqlSize = results.rows.length;
sqlResults = results;
});
});
return sqlResults;
}