-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Referencing an entities sub-entities #4
Comments
I haven't been using the 'rel' attribute as a url, but there's nothing prescribing it should be either (like the 'self' link). I just find it too verbose to do so, but that's an api implementor's decision. If using the backbone collection.get(id) semantics, then using a rel is probably not the correct identifier to use as there is no uniqueness constraint specified for the rel attribute. I think the entity would have to have a property named 'id' to match the backbone collection semantics. If you are referring to the model.get(attribute) method, then I think that should only apply to properties, and use a getEntity(rel) method to get at the sub-entities. Backbone-relational looks like it follows a similar pattern with it's getRelation()/getRelations() methods. The closest thing to an id that Siren prescribes is the 'self' link's href attribute. |
I agree, the href value is the closest thing to a unique id as specified by Siren. In addition backbone provides its own "cid", and an API implementor may choose to add an "id" property. Regarding Collections: Regarding Models: |
Don't have any practical experience with bbSiren yet, so just keep going as you are and we'll see how it goes when I get around to using it. |
There is the .entities() method which filters by className and rel. You can also use the standard backbone notation: .get() to get an entity by its "name" A name can be defined by: |
Some additional thinking is needed around what name to use when referencing sub-entities from within an entity.
The current solution is to use the "rel" attribute but strip off everything before the last slash. However, this has some limitations since a rel is a "global" relationship definition and identifying a sub-entity should, ideally, be local to the given entity.
Given the example provided on the Siren readme:
I would want to do:
and not:
The text was updated successfully, but these errors were encountered: