-
Notifications
You must be signed in to change notification settings - Fork 173
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
Allow loading entities by any field. #334
Conversation
👍 I wonder if |
(as, we expose the term "field" regardless is the internal is a property or a configurable field) |
Only missing tests. |
@amitaibu this is ready to be reviewed. |
@@ -97,6 +97,35 @@ articles after a certain date: | |||
curl https://example.com/api/articles?filter[created][value]=1417591992&filter[created][operator]=">=" | |||
``` | |||
|
|||
## Loading by an alternate ID. | |||
Some times you need to load an entity by an alternate ID that is not the regular | |||
entity ID. All that you need to do is provide the alternate ID as the regular |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entity ID. => entity ID, for example a unique ID title
@@ -86,7 +86,7 @@ public static function controllersInfo() { | |||
// POST | |||
\RestfulInterface::POST => 'createEntity', | |||
), | |||
'^(\d+,)*\d+$' => array( | |||
'^.*$' => array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we are loosing an important validation here, although I'm not sure how smart we want to be about it. Any ideas? (anyway this isn't a blocker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a big deal, since there's still validation when trying to load the entity.
Looks promising :) Some comments added. |
@amitaibu feedback implemented. |
go ahead - merge it :) |
w00t! My first PR for a work related project :-) |
mazal tov dude :) |
I've found need this several times already. I need to be able to load an entity by a unique field or property attached to that particular entity.
This is the URL schema I'm looking for:
At the same time we need to communicate to the API consumer that the canonical resource for what RESTful is returning is different. We should do that with a
Link
header and arel="canonical"
in the response. That is one of the REST principles that is really useful to normalize caches –among other things–.Real scenario
There's a Segment content type that has a unique field. We want to be able to load by that ID.
Returns: