Results 1 to 5 of 5

Thread: What is the meaning of type in association

  1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    36
    Answers
    1

    Default What is the meaning of type in association

    Hi,

    I have model with association:


    Ext.define("SimpleWeb.model.Relative", { extend : "Ext.data.Model", fields : [ { name : "id", type : "int" }, { name : "personId", type : "int" }, { name : "version", type : "int" } ], associations : [ { type : "belongsTo", model : "SimpleWeb.model.Person", associationKey : "relPerson", foreignKey : "person_id", setterName : "setRelPerson", getterName : "getRelPerson" } ] });

    this works good. Just for test I change type to hasOne and this works also good. So what is the meaning of this type? I thing important is other parameters like getter ...

  2. #2
    Sencha User
    Join Date
    Jun 2013
    Location
    Kiama, Australia
    Posts
    25
    Answers
    2

    Default

    type is so you can tell the model what type of data is coming, 'int' or 'string' or 'boolean' or 'date'

  3. #3
    Sencha User
    Join Date
    May 2013
    Posts
    36
    Answers
    1

    Default

    but now I am talking about association. Different between belongsTo and hasOne

  4. #4
    Sencha User
    Join Date
    Jun 2013
    Location
    Kiama, Australia
    Posts
    25
    Answers
    2

    Default

    ah, sorry about that. Perhaps a real life example then

    Code:
            Ext.define('Songle.model.SetListSongs', {
                extend: 'Ext.data.Model',
                idProperty: 'id',
                fields: [
                     { name:'occ', type:'int' },
                     { name:'song_id', type:'string' },
                     { name:'title', type:'string' },
                     { name:'key', type:'string' },
                     { name:'length', type:'string' }
                ],
                belongsTo: 'Songle.model.SetListWin'           
            });        
            
            Ext.define('Songle.model.SetListWin', {
                extend: 'Ext.data.Model',
                idProperty: 'setlistId',
                fields: [
                    { name: 'title', type:'string' },
                    { name: 'setlistId', type:'int' },
                    { name: 'date', type:'string' },
                    { name: 'parenttxt', type:'string' },
                    { name: 'totaltime', type:'string' }
                ],
                hasMany: [ {model: 'Songle.model.SetListSongs', name: 'songs'} ]     
            });
            
            var myStore = Ext.create('Ext.data.Store', {
                id:'SetlistWinStore',
                model: 'Songle.model.SetListWin',
                autoLoad: false
            });
    In this example you can see how all my songs "belongTo" a setlist and my setlist "hasMany" songs.

  5. #5
    Sencha User
    Join Date
    May 2013
    Posts
    36
    Answers
    1

    Default

    and did you try change it ? belongsTo change to hasMany and vice versa ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •