vendredi 27 février 2015

How may I delete using Titanium with Alloy Framework?


I am trying to delete only one record using Alloy framework:


I created in my controller .js this code to show the variables I got from a ListView:



var args = arguments[0] || {};
$.titleLabel.text = args.titulo || 'Default Title';
$.authorLabel.text = args.author || 'Default Author';


And I have created this function for deleting:



function deleteBook(){
var books = Alloy.createCollection('books');
// The table name is the same as the collection_name value from the 'config.adapter' object. This may be different from the model name.
var table = books.config.adapter.collection_name;
// use a simple query
books.fetch({query:'Delete from ' + table + ' where titulo="' + args.titulo + '"'});
}


And I invoke the function with a button, however I get this error:



[ERROR] : TiExceptionHandler: (main) [359476,359476] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,359476] - In alloy/sync/sql.js:1,69
[ERROR] : TiExceptionHandler: (main) [0,359476] - Message: Uncaught TypeError: Cannot call method 'isValidRow' of null
[ERROR] : TiExceptionHandler: (main) [0,359476] - Source: (o)?r.execute(o):r.execute(o.statement,o.params);for(var c=0,u=[];d.isValidRow
[ERROR] : V8Exception: Exception occurred at alloy/sync/sql.js:1: Uncaught TypeError: Cannot call method 'isValidRow' of null


I just want to be able for deleting records from my db.





Aucun commentaire:

Enregistrer un commentaire