Ionic 1 slow slow rendering when leave view /Sqlite update data


Hi! I developing an application using ionic1 and AngularJS.When i want to go back to previous view i must save some data into sqlite database using sqlite plugin from .When i press button to go back i see a lag when it pass from a view to another.The sqlite table structure have two columns:

->Id -primary key -integer


In this table i want to save data field as string(from json). Does anyone knows how to make this process faster? I’m using an iPad for testing. I’m posting my code here to show how save function is implemented.Thanks for any help. :slight_smile:

$scope.storeProfileDataCourses = function(data) {
           var querySelect = "SELECT * FROM Table where Id=?";
           $cordovaSQLite.execute(db, querySelect, [crewId]).then(function(res) {
               console.log('Rows:' + res.rows.length);
               if (res.rows.length > 0) {
                   var queryUpdate = "UPDATE Table SET data=? WHERE Id=?";
                   $cordovaSQLite.execute(db, queryUpdate, [JSON.stringify(data), crewId]).then(function(res) {
                   }, function(err) {
               } else {
                   console.log('Need to insert');
                   var query = "INSERT INTO Table(Id,data) VALUES (?,?)";
                   $cordovaSQLite.execute(db, query, [Id, JSON.stringify(data)]).then(function(res) {
                       console.log("INSERT ID -> " + res.insertId);
                   }, function(err) {