2

So, I am trying to connect models using schema and namespace, but I get this error: " Error: C2008: Requirement had no matching files (ExtReactModels.model.Item)". This is done in ExtReact. Should I even declare schema and namespace, or just import the ordinary objects? The most import parts of the code are:

  1. RootTypeModel:

export default Ext.define("ExtReactModels.model.RootType", {
 extend: 'Ext.data.Model',
 schema: {
  namespace: 'ExtReactModels.model'
 },
 requires: [
  'Ext.data.proxy.Rest', 'ExtReactModels.model.Item'
 ],
 idProperty: 'rootTypeId',
 fields: [
  /* ... */
 ],
 proxy: {
  type: 'rest',
  url: '/rootTypes'
 },
 hasOne: [{
  model: 'ExtReactModels.model.Item', name: 'item', associationKey: ">item", instanceName:"item",
  getterName: "getItem", setterName: "setItem"
 }]
});
  1. ItemModel:

export default Ext.define("ExtReactModels.model.Item", {
 extend: 'Ext.data.Model',
 schema: {
  namespace: 'ExtReactModels.model'
 }
 requires: [
  'Ext.data.proxy.Rest'
 ],
 idProperty: 'itemId',
 fields: [
  /* ... */  
 ],
 proxy: {
  type: 'rest',
  url: '/items'
 },
 hasOne: [{
  model: 'ExtReactModels.model.Application', name: 'application', associationKey: ">application", instanceName:"application",
  getterName: "getApplication", setterName: "setApplication"
 }]
});

1 Answers1

1

So I fixed this by using an ordinary object which I have imported for Item and also I have defined separated const which will hold the definition of Schema and namespace and which will be repeated in separate models, and now I can use this definition in different models:

import itemModel from './ItemModel';
import {baseModel} from './BaseModel';

export default Ext.define("ExtReactModels.model.RootType", {
 extend: 'Ext.data.Model',
 baseModel,
 requires: [
  'Ext.data.proxy.Rest'
 ],
 idProperty: 'rootTypeId',
 fields: [
  /* ... */
 ],
 proxy: {
  type: 'rest',
  url: '/rootTypes'
 },
 hasOne: [{
  model: itemModel, name: 'item', associationKey: ">item", instanceName:"item",
  getterName: "getItem", setterName: "setItem"
 }]
});

If someone found a different way for this, please let me know!