Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.
This repository was archived by the owner on Jul 9, 2026. It is now read-only.

Call toJson in representer logic #7

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.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions