Data first

All our models will inherit from a base model, which will be used to specify the following command:

// app/model/BaseModel.js
Ext.define('Instrumatics.model.BaseModel', {
    extend: 'Ext.data.Model',

    schema: {
        namespace: 'Instrumatics.model',
        urlPrefix: 'http://localhost:3000',
        proxy: {
            type: 'ajax',
            url: '{prefix}/{entityName:uncapitalize}'
        }
    },
});

Note

We've assumed that we have an API server running at localhost on port 3000 and supplied this information as the URL prefix.

We used the schema configuration in the last chapter, but now that we're about to use it with multiple models, it really comes into its own. In each of the models that inherit from BaseModel, the model's name will be inserting into the proxy URL in place of the entityName ...

Get Ext JS Application Development Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.