jeudi 28 janvier 2016

Same base64 image inserted in sqlite bug

i'm trying to make a gallery to learn ionic framework, when I insert different images in the sqlite database, the list view works, but if I insert an image which is already in the base, there is no images in the list, I don't understand why.

the create table query :

var db = $cordovaSQLite.openDB("project.db");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS images (id integer primary key, data longblob)");

The insert query :

var db = $cordovaSQLite.openDB({ name: "project.db", bgType: 1 });

  var save = function(data, calback) {
    var query = "INSERT INTO images (data) VALUES (?)";
    $cordovaSQLite.execute(db, query, [data]).then(function(res) {
      alert("insertId: " + res.insertId);
      calback();
    }, function (err) {
      alert(JSON.stringify(err));
    });
  };

The list query :

var db = $cordovaSQLite.openDB({ name: "project.db", bgType: 1 });
  var query = "SELECT * FROM images";
  $cordovaSQLite.execute(db, query, []).then(function(data) {
    for(var i = 0; i<data.rows.length; i++){
      $scope.all.push(data.rows.item(i).data);
    }
  }, function (err) {
    alert(JSON.stringify(err));
  });

Aucun commentaire:

Enregistrer un commentaire