-
Notifications
You must be signed in to change notification settings - Fork 23
Refactor .find() #127
Comments
@Nexbit Hello again :) Looking at the code, I don't think this makes sense. .find() is a public method used to fetch (find) data for a specific resource. If (for instance) you want to get the delegates you have a couple options: Association:
Repository:
The repository way is a custom implementation. This has been kept open to allow flexibility. Therefor, I'd say no to refactoring find() (which has a very specific purpose). Something like this could work, but is a breaking change: findPath(path, criteria, raw) {
if (path[0] !== '/') {
path = `${this.resource}/${path}`;
}
} This follows the convention of absolute and relative paths. I'd need a vote on this though. |
@RWOverdijk I agree with your reasoning, and maybe the |
just to make sure: you do know that criteria is used as part of the path if it is a number or string only? so, find(1) translates to eg api/users/1 |
@doktordirk Yeah I used that to retrieve single resources directly, but my original issue was with |
so you.d need a entity.find then? |
I think it would be nice to have a repository method similar to .findPath(), but .call(). Same parameters, but it would call an action on top of the root path. In other words a User repository would call "user/list/1" for .call("list",1). I really need this for ASPNetCore where the Controller is "user" but it typically takes an action name as well.
I think this is the same issue that @Nexbit was having. |
If it does exactly the same, you can just extend it in your application. |
@RWOverdijk Ok. I actually tried to extend it, but I am missing something in how I set it up. I Subclassed Repository to AppRespository. Then then set it as the Repository using the decorator on the Contact Entity Type.
But then when I attempted to get an instance in the viewmodel:
It returned a regular repository, not an AppRepository so I could call my custom methods. Am I doing something wrong in the wireup? |
@gregoryagu Did you specify the @resource on the entity as 'contact'? Also, it should be possible to overwrite the default repository. Simply register your custom repository as |
Closing this due to inactivity. Feel free to reopen if this question still exists :) |
Yes, this was resolved. Sorry, forgot to update this. Thanks very much. |
#119 (comment)
Refactor find to accept path and criteria (relative to resource).
The text was updated successfully, but these errors were encountered: