You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
than we need to add another useInterceptor before our representer that calls this for our orm objects. It's required for orm entities to be serialized. For example; when you have an nested collection, without toJson it'll return an object if it's empty.
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
to
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.
The text was updated successfully, but these errors were encountered: