1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    1
    Vote Rating
    0
    odinkubometr is on a distinguished road

      0  

    Default Ext.data.Model: idProperty is the primary key?

    Ext.data.Model: idProperty is the primary key?


    Я правильно понимаю, что Ext.data.Model: idProperty - это первичный ключ?
    Если да, то как указать несколько полей?

    Do I understand correctly that Ext.data.Model: idProperty is the primary key?
    If so, how to specify multiple fields?
    Last edited by odinkubometr; 7 May 2012 at 3:51 AM. Reason: eng lang

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,000
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    The idProperty us the unique field ID and is not to be confused with primary/compound index keys.

    Regards,
    Scott.

  3. #3
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by odinkubometr View Post
    Do I understand correctly that Ext.data.Model: idProperty is the primary key?
    If so, how to specify multiple fields?
    Just to elaborate a bit on Scott's (correct) answer ...

    The idProperty is often the primary key, but if the actual primary key does not work in your situation or your table uses a compound key, the idProperty will be some other unique field (perhaps a rownum).

    Best practice, in my experience, is to use your Primary Key as your idProperty whenever possible.

    As an aside, and not directly relevant to Ext JS: it is also a good idea for every entity in your ERD to have a single, unique primary key (identity). The id is often not unique amongst all entities, e.g., "1" is a common choice. Even so, UUID's are particularly attractive for implementing complex, distributed transactions.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  4. #4
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,407
    Vote Rating
    6
    stever will become famous soon enough stever will become famous soon enough

      0  

    Default


    I do find it strange that people that do a lot of enterprise type software use things like ORMs and RAILs, etc., which all support compound keys and many-to-many, but Sencha products which are targeted to the same audience leave that out. Sigh. EmberJS and Backbone associated have such support.

    Anyhow, what I found useful in the case of the compound key in the specific case where a hasMany uses the parent as a prefix, is to just use the last part/column/field of the compound key as the "primary" and apply some simple overrides to the Model to fill in the others from the parent (using some added primaryKey definition data in the model class). Works rather well, and in 40 loc.

    As for many2many -- like products and categories -- you are out of luck on easy solutions (that I know of at least).