Last active
June 17, 2016 13:50
-
-
Save brunodasilvalenga/76922ecc0af41a52f167959659987f9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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