Skip to content

Instantly share code, notes, and snippets.

@tlenclos
Last active December 17, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlenclos/5567944 to your computer and use it in GitHub Desktop.
Save tlenclos/5567944 to your computer and use it in GitHub Desktop.
exports.extendCollection = {
deleteAll : function() {
var collection = this;
db = Ti.Database.open(collection.config.adapter.db_name);
db.execute(squel.delete().from(collection.config.adapter.collection_name));
db.close();
collection.trigger('sync');
},
findOneBy : function(field, value) {
this.fetch({
query: squel.select().from('evenements').where(field+' = '+value).limit(1).toString()
});
var result = this.toJSON();
return result[0];
},
findOneById : function(value) {
return this.findOneBy('id', value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment