I have a separate schema called "api" where all my "front-end" functions reside. My API server only have access to this schema. This works great for getting information out of the database in a controlled way.
To insert data in a controlled way I can either create functions in the api schema. But functions with many parameters (i.e. all fields to be inserted) are cumbersome to work with because:
It's easy to mix up parameters in calls
I don't know of any syntax to call functions with named parameters
So, I'm thinking of creating "proxy-views" in my api schema instead. The views would show no data (i.e. WHERE false). The API server would do ordinary inserts into these views and a trigger would take care of the actual insert logic.
The code for inserting data with INSERT statements are more readable than calling functions with a list of unnamed parameters.
- Have I missed anything?
- Is this a bad idea?
- Maybe there is someway to name the input parameters for functions?
Thanks!