Skip to content

Support ID field for has many associations #29

Description

@danschultz

Has many associations are empty until you call HasManyAssociation.load(). This method invokes the DataSource.belongsTo(). I think we can simplify the data source by having the backend pass back an array of record IDs for the association. When the association is accessed, it instantiates records for each of the IDs.

When HasManyAssociation.load() is called, it will do a batch retrieve call for each of the association's records. Alternatively, you can also call load() on each of the records to load them individually.

public class Person extends Record
{
    [HasMany(idField="childrenIds", recordType="myapp.Person")]
    public var children:HasManyAssociation;

    public var childrenIds:Array;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions