The ability to create a table and insert data into it is not of much use if we don't know how to retrieve that data and present it in a useful way to the user! We'll now introduce the concept of resultSet
(or recordSet
, if you prefer) in SQLite and see how to retrieve data via this resultSet
object, which can be collected and returned in an array format suitable for use within a TableView.
In your database.js
file, add the following function under the db.deleteFavorite
function:
db.getFavorites = function() { var sql = "SELECT * FROM favorites ORDER BY title ASC"; var results = []; var resultSet = db.database.execute(sql); while (resultSet.isValidRow()) { results.push({ id: resultSet.fieldByName('id'), title: resultSet.fieldByName('title'), data: { title: resultSet.fieldByName('title'), description: resultSet.fieldByName('description'), link: resultSet...