Skip to content

Association/Attribute name attribute exposed but not supported #97

Open
@wadetandy

Description

@wadetandy

Turns out we never actually implemented attribute remapping, even though we exposed it in configuration options.

Given an api response like:

{
  data: {
    id: '12',
    type: 'posts',
    attributes: {
      post_name: 'The Post',
      body: 'body text',
   },
   relationships: {
     the_author: {
       id: '1',
       type: 'people'
     }
  }
  // ...
}

Then the following should map correctly to those attributes both reading from and writing to the API:

@Model()
class Post extends ApplicationRecord {
  @Attr body : string
  @Attr({ name: 'post_name' }) name : string
  @BelongsTo({ name: 'the_author' }) author : Person
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions