Models and persistence
Ext JS 4 models are similar to JPA entities in that they define data fields that represent columns in the underlying database tables. Each model instance represents a row in the table. The primary key field is defined using the idProperty
of the model, which must match one of the field names. The User
model can now be updated as shown:
Ext.define('TTT.model.User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'username', type: 'string' },
{ name: 'firstName', type: 'string' },
{ name: 'lastName', type: 'string' },
{ name: 'fullName', type: 'string' },
{ name: 'email', type: 'string' },
{ name: 'password', type: 'string' },
{ name: 'adminRole', type: 'string' }
],
idProperty: 'username'
});
Defining the proxy
Each model can be made persistent aware by configuring an appropriate proxy. All loading and saving of data is then handled by the proxy when the load
, save
, or destroy
method on the model...