Skip to content

Unable to add an empty array of embedded entities with different hrefs #65

@brabster

Description

@brabster

Hi,

Issue #58 allows empty arrays of embedded entities, but I can't see how to use it where I need to map objects that have self-refs defined by their own properties (eg. '/people/{id}') in an array that might be empty.

I think I'm looking for rep.embed to support an array-arg based variant (like rep.link) such as embed(rel, embeddables) where toEmbed is an object with self and entity properties. Then, I can call

rep.embed('friends', rawFriendsArray.map(function(friend) {
  var selfHref = '/people/'+friend.id;
  delete friend.id; 
  return {self: selfHref, entity: friend};
}));

...and rawFriendsArray happens to be empty it'll just embed an empty array.

Happy to submit a PR for this if I'm not missing a better way to do it already!

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