Skip to content

Call toJson in representer logic #7

@driescroons

Description

@driescroons

In listRepresenter, we call the toJson method. Why don't we do this for Representer?

Argument could be made here that for creation routes, these entities don't have a toJson method, however, this can be simple fixed by returnijng a wrapped entity.

from

return getById(id);

to

return wrap(await getById(id));

This comes in especially handy when you have a parent - children entity, that upon initialization has an empty collection. Without the wrap, and with em.create, it will return the parent with an object children, even though it's an array. Wrapping in every create and toJsoning in the representer fixes this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions