I am new to javascript promises, I am using below code from NativeScript to query sqlite database and just want to return true
if row exists and false
otherwise:
function hasBookmark(url) {
(new Sqlite("pakjobs.db")).then(db => {
db.all("SELECT url FROM bookmarks WHERE url=?", [url]).then(rows => {
return rows.length ? true : false;
}, error => {
console.log("hasBookmark ERROR", error);
return false;
});
}, error => {
console.log("hasBookmark ERROR", error);
return false;
});
return false;
}
However function ALWAYS returns false
.
Can anybody tell how do I return true
if row exists and false
otherwise ?
Thanks for the help
Aucun commentaire:
Enregistrer un commentaire