-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 option to only generate certain HTTP methods for a DB view #1647
Comments
I think this currently depends on whether the view is updateable or not: postgrest/src/PostgREST/App.hs Line 279 in 302d4e1
A view is updateable if either you have some triggers defined for that or it is auto-updateable. See the postgres docs for when that is the case - the So your view seems to be auto-updateable right now. The question then is: How is it possible to prevent auto-updateability? It seems like a view is not updateable anymore when it contains the
So maybe you can just append |
Thanks for the suggestion @wolfgangwalther. I've tested your suggestion but it looks as the methods are still being generated. Example query:
Switching to a |
@wolfgangwalther never mind. I was misreading the docs you suggested.
In my example the |
This "hack" seems like something that we could document somewhere. |
While the hack to prevent auto-updateability is one thing, looking at the code for |
There were two actionable items here:
|
Description of issue
As discussed earlier in the Gitter, it would be nice if there would be an option to avoid generation of HTTP methods for certain views.
Example:
If you have 1 table which is called
src.orders
and two views on it which are namedapi.orders_per_hour
andapi.orders_per_day
. It would be a nice addition if there would be an option to only allow certain HTTP methods (e.g. only GET). So that it's clear for the users of the API that certain methods are not to be used at all. This especially applies if you communicate the API spec with something such asSwagger
.(Expected behavior vs actual behavior)
Currently when a view is created, PostgREST automatically generates a GET, POST, DELETE, and PATCH. In cases where the view contains a
group by
it does seem to only create a GET.The text was updated successfully, but these errors were encountered: