7 May 2012 3:48 AM #1
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
8 May 2012 12:41 PM #2
The idProperty us the unique field ID and is not to be confused with primary/compound index keys.
8 May 2012 3:32 PM #3
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.
8 May 2012 7:24 PM #4
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).