-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Custom endpoints for CRUD actions #270
Comments
I believe that using Active Record, like the one offered by this package, might not be the best approach for handling save and get requests. I am contemplating a separation of these responsibilities into two distinct components: Command, represented by ModelService (which can potentially make use of this package), and Query, embodied by Model (utilizing this package). This approach aligns with the principles of Command–Query Separation (CQRS). In summary, the |
Is there a way to implement custom endpoints for CRUD actions using the current setup of vue-api-query?
There is a
.custom()
method to create a custom endpoint for a model which works great however is only usable for GET requests to my understanding.I would like to be able to make custom endpoints for certain actions on a model e.g.:
/model-resource/model-action
.Currently, I do this by creating a new model stored away in an actions namespace with as resource the action endpoint e.g.:
I then build up the query as:
new ActionModel({}).for(Model);
This results in an endpoint that I can use for my custom model actions, however, this approach is quite ugly as you are creating a model only to use its
resource()
method.This is essentially misusing the relations setup from the
.for()
method by creating a new ActionModel which doesn't have an ID.Could it be possible to use the
.custom()
method for CRUD actions, or is there a way that we could create specific endpoints on the model for certain actions?The text was updated successfully, but these errors were encountered: