mercredi 11 février 2015

SQLite. Cordova. Can't insert more than 995 rows

I'm using:



I use SQLite plugin with Angular wrapper. Function self.insert() inserts a row in table "stores". Function self.query() handles all queries and possible errors. Function $scope.init() in controller is used to insert 20000 rows in table "stores".


The problem: Only first 996 rows are inserted. No errors. Sometimes 995 or 997 rows.


Note: Everything works in WebSQL (Chrome). All 20000 rows are inserted.


Thank you in advance!


Factory 1:



self.query = function(query, parameters) {
return $cordovaSQLite.execute(db, query, parameters).then(function(result) {
//console.log(result);
return result;
}, function (error) {
console.log(error);
return error;
});
};


Factory 2:



self.insert = function(shop) {
var parameters = [shop.storeId, shop.storeName, shop.address, shop.post, shop.city, shop.lat, shop.lng, shop.open, shop.favorites];
return DB.query("INSERT INTO stores (storeId, storeName, address, post, city, lat, lng, open, favorites) VALUES (?,?,?,?,?,?,?,?,?)", parameters);
};


Code in controller:



$scope.init = function(){
DB.query("DROP TABLE IF EXISTS stores");
DB.query("CREATE TABLE IF NOT EXISTS stores (storeId integer,storeName text, address text, post text, city text, lat integer, lng integer, open text, favorites integer)");
json_service.getJson().then(function(data){
for (var i = 0; i < data.length; i++){
for (var j = 0; j < data[i].data.shops.length; j++) {
var coordinates = data[i].data.shops[j].g.split(",");
var oneStore = {
storeId: i + 1,
storeName: data[i].data.title,
address: data[i].data.shops[j].a,
post: data[i].data.shops[j].p,
city: data[i].data.shops[j].s,
lat: coordinates[0],
lng: coordinates[1],
open: data[i].data.shops[j].t[0],
favorites: 0
};
stores_service.insert(oneStore);
}
}
});
};

Aucun commentaire:

Enregistrer un commentaire