Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Associations should be able to alias a different property #20

@epixa

Description

@epixa

The current behavior of associations is to rely on the data in a property on the model by the same name, so:

comment.hasOne('article');
comment.article() // proxies using the value of the `article` property

This should remain the default behavior, but you should be able to optionally define a proxy as an alias for a different value, for example:

comment.hasOne('article', { alias_of: 'article_url' });
comment.article() // proxies using the value of the `article_url` property

One important thing to consider: when an alias is set up in this way, it's important that we can still define article_url as an attribute but do not have to define it as an attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions