Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    21
    Vote Rating
    0
    K4T is on a distinguished road

      0  

    Default Answered: Many assocations to one model

    Answered: Many assocations to one model


    Hello! I have task model which have two associations to one model - User model. Those associations create two getters for me: getAssignedTo() and getAssignedBy() which should allow me to get users names by id (foreign keys). I think those associations are collide and I dont know how to resolve this. For example:

    Code:
            console.log(record);
    
            record.getAssignedTo(function(user, operation) {
                console.log('Assigned To: ' + user.get('name'));
            }, this );
    
    
            record.getAssignedBy(function(user, operation) {
                console.log('Assigned By: ' + user.get('name'));
            }, this );
    That example will log:

    gacq.jpg

    As you see getAssignedBy() returns empty string :/ If I remove accocation for assignedToId foreign key than getter getAssignedBy() will work because there is only one assocation to User model inside Task model. How I can resolve this issue?

    Task Model:
    Code:
    Ext.define('Tasks.model.Task', {
        extend: 'Ext.data.Model',
    
    
        fields: [
            {name: 'id',            type: 'int'},
             ...
            {name: 'assignedToId',  type: 'int',        defaultValue: 1}, //default value for simulating logged user
            {name: 'assignedById',  type: 'int',        defaultValue: 1}  //default value for simulating logged user
        ],
    
    
        associations: [
            { type: 'belongsTo', model: 'Tasks.model.User', primaryKey: 'id', foreignKey: 'assignedToId', getterName: 'getAssignedTo' },
            { type: 'belongsTo', model: 'Tasks.model.User', primaryKey: 'id', foreignKey: 'assignedById', getterName: 'getAssignedBy' }
        ],
    
    
        proxy: {
            ...
        }
    
    
    });
    User Model:
    Code:
    Ext.define('Tasks.model.User', {
        extend: 'Ext.data.Model',
    
    
        fields: [
            {name: 'id',    type: 'int'},
            {name: 'name',  type: 'string'}
        ],
    
    
        hasMany: {model: 'Tasks.model.Task', name: 'tasks'},
    
    
        proxy: {
            ...
        }
    
    
    });


  2. #2

Thread Participants: 1

Tags for this Thread