View Full Version : How models relate to each other

6 Aug 2012, 3:40 PM
When you specify the relationship models have to each other (using the belongsTo for example), how does the model know what field to use in the parent model to link to? So for example, if I have a model named book and I add belongsTo: 'author', how does the book model know what field to link to for the author model? Does it default to 'id' and if so can you override that default?

6 Aug 2012, 7:13 PM
You should look at primaryKey (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.association.BelongsTo-cfg-primaryKey) and foreignKey (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.association.BelongsTo-cfg-foreignKey).

7 Aug 2012, 7:45 AM
Thanks, this answered my question