PDA

View Full Version : [CLOSED] Scarce documentation for associations



c2c-guinness
18 Apr 2011, 1:16 AM
What are the acceptable parameters for hasMany and belongsTo associations when creating them as part of a regModel call?

The documentation never explains this properly.

The "Model" documentation only mentions 3 or 4 parameters and the association documentation (configuration options) mentions parameters that are not valid as parameters or replaced/aliased by those in the model documentation.

When can we expect to see this explained?

Thanks,
Luke

c2c-guinness
18 Apr 2011, 3:23 PM
You mentioned updating the documentation for primaryKey in another posting.

I think its more than that. You can see that the configuration options defined by the hasMany documentation do not correlate to the configuration options used in the Model documentation.

For example, Model denotes a field named "model" whereas hasMany denotes a field named "ownerModel". In the code it seems like "name" and "associationName" are both ways of naming the association.

Words like "owner model" also creates confusion. Is that the model the association declaration is being applied to, or is that the model which contains the "hasMany".

As an example, if "user" belongs to "person", which model is the owner model in the belongsTo declaration, which is a part of user, and which model owns the hasMany declaration, which is part of the person declaration.

I mean, technically, "person" is always the owner/parent, and if thats the case, "ownerField" would always be "person".. so doesnt that create a need for localField, which isnt an option at all?

And the field "primaryKey" implies that it should contain the primary key's field name of the current model being defined, but what if primaryKey is not used in the association? Does primaryKey in fact mean "localKey" or "localField" ?

Thanks,
Luke