Hi.

I have a Extjs model person and model phoneNumber (also respective model on database)
" person has many phoneNumber "

On ExtJs the model person has a association hasMany phoneNumber.

When i create a person record i add the phoneNumbers to that record.
Then i send to save the person record.
Code:
Ext.onReady(function() {
    Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
    
    Ext.define('Phone', {
        extend: 'Ext.data.Model',
        fields: [
            {name:'phoId'        ,type:'int'},
            {name:'perId'        ,type:'int'},
            {name:'phoNumber'    ,type:'string'},
        ],
        idProperty: 'phoId',
        proxy: 
        {    type: 'direct',
            api:{
                create    : phoQuery.insert,
                read    : phoQuery.select,
                update    : phoQuery.update,
                destroy    : phoQuery.delete
            }
        }
    });

    Ext.define('Person', {
        extend: 'Ext.data.Model',
        fields: [
            {name:'perId'    ,type:'int'},
            {name:'perName'    ,type:'string'},
        ],
        associations: [
            {     type: 'hasMany', model: 'Phone', name : 'phones', associationKey: 'phone' }
        ],
        idProperty: 'perId',
        proxy: 
        {    type: 'direct',
            api:{
                
                read    : perQuery.select,
                create    : perQuery.insert,
                update    : perQuery.update,
                update    : perQuery.delete,
                
            }
        }
    });


    Ext.define('PersonStore', {
        extend: 'Ext.data.Store',
        model: 'Person',
        autoLoad: false
    });
    
    // Logic
    var myPerson = Ext.create('Person');
    
    myPerson.set('perName','peter');
    
    myPerson.phones().add(
        {phoNumber : '12342425'},
        {phoNumber : '056-23-3232'}
    );

    myPerson.save();
    
});
this save() only sends the person data. How can i send the phone numbers too ? in the same call.

In the server side i have a function (perInsert) to insert a new person to the dabase, and then, save his phones if theres any, using the person Id that the database asigned after the person insert. this is working.

The problem is to send person + his phones to that server function.

other ways im trying
Send 2 saves (save and sync)
Code:
  myPerson.save();
  myPerson.phonesStore.sync();
cant do this because those phone numbers dont have the person id (perId) set yet so the server wont know to which person they belongs to. I cant set phones perId before the sync because the person doesnt have perId set neither, is set on the server and when that call is done ill know the perId that the server responded.

Wait for person.save() to end
i could wait (in some way i dont know) for the save() to return and then set the perId to all phones and do a sync() but that means " go to server to save person, back to client with perId info, go to server to save phones" too much calls when with raw ajax i know i can send all the data in 1 call and save all data .
Anyway this is a solution at least, but i dont know how to wait for save() to return

Use proxy.batch
im reading the proxy.batch() doc, maybe with this i can send the Person model and the phone models in 1 call, but batch will send my Person to its proxy create method (perInsert) and then phones to (phoInsert). Thinking this still.

have hours reading docs but cant find anything, im sad.
any ideas on this ? how to send associated model on record.save() or "in one call to the server" ?
(sorry for my bad english)