Skip to content

Instantly share code, notes, and snippets.

@brunodasilvalenga
Last active June 17, 2016 13:50
Show Gist options
  • Save brunodasilvalenga/76922ecc0af41a52f167959659987f9c to your computer and use it in GitHub Desktop.
Save brunodasilvalenga/76922ecc0af41a52f167959659987f9c to your computer and use it in GitHub Desktop.
getAluno(queryText=''){
queryText = queryText.toLowerCase().replace(/,|\.|-/g,' ').trim();
queryText = '%'+queryText+'%'
function asPlainObjectCollection(data) {
let array = []
let rows = !!data.res.rows.length ? data.res.rows : array
for (let i = 0; i < data.res.rows.length; i++) {
array.push(data.res.rows.item(i))
}
return array;
}
if (queryText === ''){
return this.storage.query('SELECT * FROM alunos').then(asPlainObjectCollection);
} else {
return this.storage.query('SELECT * FROM alunos WHERE firstName LIKE ? OR lastName LIKE ?', [queryText, queryText]).then(asPlainObjectCollection);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment