Json 一个模型中有多个关联

Json 一个模型中有多个关联,json,sencha-touch-2,associations,has-many,Json,Sencha Touch 2,Associations,Has Many,我有以下JSON结构: { orderId : '00410', name : 'Zuiger', productionQuantity : '4', materials : [ { materialId : 'ALU.BALK.10X70',

我有以下JSON结构:

{
                orderId : '00410',
                name : 'Zuiger',
                productionQuantity : '4',
                materials : [
                    {
                      materialId    : 'ALU.BALK.10X70',
                      description   : 'Aluminium balk 10 x 70',
                      quantityPP    : '70mm',
                      totalQuantity : '0.4'
                    },
                    {
                      materialId    : 'ALU.BALK.10X70',
                      description   : 'Aluminium balk 10 x 70',
                      quantityPP    : '70mm',
                      totalQuantity : '0.4'
                    }],
                operations : [
                    {
                      operationId   : 'ZAGEN',
                      lineNr        : '10',
                      description   : 'Zagen groot',
                      started   : false
                    }, 
                    {
                      operationId   : 'FR003',
                      lineNr        : '20',
                      description   : 'Frezen Heidenhein',
                      started   : true
                    }] 
            }
所以我有一份订单,里面有一份材料清单和/或一份操作清单。此JSON当前位于使用数据标记的存储文件中,并自动加载。这是为了测试目的

此订单所使用的模型包含2个与物料和操作有许多关联的订单:

Ext.define('wp-touch.model.Order', {
extend: 'Ext.data.Model',

requires: [ 
           'wp-touch.model.Material', 
           'wp-touch.model.Operation'
           ],

config: {
    idProperty: 'Id',       
    fields: [
            { name: 'orderId',  type: 'string'},
            { name: 'name',     type: 'string'},        
            { name: 'productionQuantity', type: 'string'},
    ],
    associations: [
              { 
                type: 'hasMany',
                associationKey: 'materials',
                model: 'wp-touch.model.Material',
                name: 'material',
                primairyKey: 'materialId',
                foreignKey: 'orderId'
              },
              { 
                type: 'hasMany',
                associationKey: 'operations',
                model: 'wp-touch.model.Operation', 
                name: 'operation',
                primairyKey: 'operationId',
                foreignKey: 'orderId'
              }   
    ],

}});
加载存储时,它只加载第一个hasMany。当我清空JSON消息中的materials数组时,它会很好地加载到操作中。因此,它似乎只加载其中一个具有多个关联。有办法解决这个问题吗

以下是材料和操作模式

Ext.define('wp-touch.model.Material', {
extend: 'Ext.data.Model',

config: {
    idProperty: 'Id',

    fields: [
            { name: 'materialId',   type: 'string'},
            { name: 'description',  type: 'string'},
            { name: 'quantityPP',   type: 'string'},
            { name: 'totalQuantity',type: 'string'},
            { name: 'orderId',      type: 'string'}
    ],
    belongsTo: [
                { 
                    model: 'wp-touch.model.Order',
                    name: 'order',
                    primairyKey: 'materialId',
                    foreignKey: 'orderId' 
                }
    ]
}});

Ext.define('wp-touch.model.Operation', {
extend: 'Ext.data.Model',

config: {
    idProperty: 'Id',

    fields: [
            { name: 'operationId',  type: 'string'},
            { name: 'lineNr',       type: 'int'},       
            { name: 'description',  type: 'string'},
            { name: 'started',      type: 'boolean'},
            { name: 'orderId',      type: 'string'}
    ],
    belongsTo: [
                { 
                    model: 'wp-touch.model.Order', 
                    name: 'order',
                    primairyKey: 'operationId',
                    foreignKey: 'orderId' 
                }
    ]
}});

您拼写的
primaryKey
不正确。您是对的,我已修复了此问题,但这似乎不是问题。