Skip to content

Accessing metadata on single records #155

@therealcljohn

Description

@therealcljohn

Hi @RooTooZ,

Edit: I added a merge request down below because I could not find how to achieve what I need overnight.

I'm refering to GH-64. This pull request adds access to metadata and it works quite well for collections. But how can I access the metadata of a single record?

I tried the following code but it does not seem to work. The documentation has an example only for the findAll-method so I'm quite unsure if accessing meta of single records is currently possible.

Querying:

            this.datastoreService.findRecord<Role>(Role, id, {
                include: 'permissions,users'
            }).subscribe(
                (role: Role) => {
                    console.log(role.meta);
                    console.log(role.getMeta());
                    this.role = role;
                },
                (errorResponse) => {
                    this.locationService.back();
                }
            );

Role model

@JsonApiModelConfig({
    type: 'roles',
    meta: JsonApiMetaModel
})
export class Role extends JsonApiModel {
    @Attribute()
    name: string;
    @Attribute()
    description: string;

    @HasMany()
    users: User[];
    @HasMany()
    permissions: Permission[];
}

Can you clarify this for me?

Best regards
Clemens

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