Skip to content

Instantly share code, notes, and snippets.

@JigarM
Forked from aaronksaunders/app_snippet.js
Created March 1, 2013 20:37
Show Gist options
  • Save JigarM/5067592 to your computer and use it in GitHub Desktop.
Save JigarM/5067592 to your computer and use it in GitHub Desktop.
// get the collection object
Alloy.Collections.instance("Fugitive");
// delete all items
Alloy.Collections.Fugitive.deleteAll();
exports.definition = {
config : {
"columns" : {
"name" : "TEXT",
"captured" : "integer",
"url" : "TEXT",
"capturedLat" : "real",
"capturedLong" : "real"
},
"defaults" : {
"name" : "",
"captured" : 0,
"url" : "",
"capturedLat" : "",
"capturedLong" : ""
},
"adapter" : {
"type" : "sql",
"collection_name" : "fugitives"
}
},
extendModel : function(Model) {
_.extend(Model.prototype, {
});
// end extend
return Model;
},
extendCollection : function(Collection) {
_.extend(Collection.prototype, {
deleteAll : function() {
var collection = this;
var sql = "DELETE FROM " + collection.config.adapter.collection_name ;
db = Ti.Database.open(collection.config.adapter.db_name);
db.execute(sql);
db.close();
}
});
// end extend
return Collection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment