$cordovaSQLite delete syntax


#1

Hi guys, I am trying to delete a row of data from my SQLite table, I have been using the following syntax. NB. itemIndex is a passed parameter into a function where this code is called

$cordovaSQLite.execute(db, ‘delete from expenses where id = ?’, [itemIndex]);

I’ve put the query into a separate variable

var query = “delete from expenses where id = ?”;

and then ran it like so

$cordovaSQLite.execute(db, query, [itemIndex]);

still no luck, any advise


Problem with sqlite delete by id, item undefined
#2

This works for me like a charm

    deleteRecord: function(id){
      var query = "DELETE FROM records WHERE id = '"+id+"'";
      $cordovaSQLite.execute(db, query, []).then(function(results) {
      }, function (err) {
          console.error(err);
      });
    }

#3

it’s working for me thanks