Skip to content

Instantly share code, notes, and snippets.

@sergiomichels
Created August 16, 2013 23:46
Show Gist options
  • Select an option

  • Save sergiomichels/6254470 to your computer and use it in GitHub Desktop.

Select an option

Save sergiomichels/6254470 to your computer and use it in GitHub Desktop.
Ext.define('Bookmarks.model.Category', {
extend : 'Ext.data.Model',
fields : [{
name : 'name',
type : 'string'
}, {
name : 'description',
type : 'string'
}, {
name : 'parent.id',
type : 'int'
},{
name : 'qtip',
type : 'string',
convert : function(value, model) {
return model.get('description')
}
}],
validations: [
{type: 'length', field: 'name', max: 30},
{type: 'length', field: 'description', max: 100}
],
belongsTo : [
{
model: 'Category',
name: 'parent',
associationKey: 'parent',
foreignKey: 'parent.id'
}
],
hasMany : [{
model : 'Category',
name : 'subcategories',
associationKey : 'subcategories',
foreignKey : 'category_id'
}],
proxy : {
type : 'rest',
url : '../rest/category',
reader : {
type : 'json',
root : 'data'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment