Disable async db call

I am using this code to get data from database. but it always prints the result of this line console.log('outside ret data ' + retData); as undefined/null. because $cordovaSQLite.execute is an async call. How can i stop this until i get the result in the retData object. Please help


var retData = []; 
$cordovaSQLite.execute(db, "SELECT * FROM suppliertypes", []).then(function (res) {
     console.log("total rows found: " + res.rows.length);
     retData = res;

   }, function (err) {
            console.log("Error looking up Supplier types: " + err);

console.log('outside ret data ' + retData);
return retData;

the magic word is promise ;).

Search for promises and then take a look at angulars $q service.