rpc/primary_keys and rpc/foreign_keys response
gonzalomelov opened this issue · 2 comments
I'm not able to set the create/edit mode for my database tables. Is there any documentation in order to understand the configuration or responses that have to be made in these methods?
Hey, sorry the documentation is still in progress (progress is pretty much halted right now due to work). But give me until tomorrow evening, I'll reply here with the information you need.
But basically, it's a psql function, and a setting in the config.json file before the feature can work correctly. Also, of course, you'd need to configure HTTPS and what not to ensure basic security.
To be able to edit a table: the table must have primary key defined + a primary key function also must exist in the database + the user must also have edit privileges.
- /data/config.json should have the following settings to indicate the db has the primary_keys() function:
{
databases: [
url: "https://...",
"primaryKeyFunction": true,
"foreignKeySearch": true
}
- Execute the 4 SQL scripts available in the repository at /scripts. They are:
- Authentication.sql (change the secret on line 104, and the credentials on lines 115-117) (Creates the auth framework using the db to validate credentials)
- CREATE FUNCTION.sql (has the primary_keys() function which allows the front-end to uniquely identify one row to edit it) (foreign_keys() function is optional for the search box)
- CREATE_ROLE.sql (change database and table names as necessary) (grants privileges to read and edit users)
- CREATE TABLE change_log.sql (to keep track of edits made to the database)
- Then you can login using the edituser credentials defined in Authentication.sql file.
I could've used a commercial paid/free auth services but I wanted the PostgreSQL db to contain everything needed to share data including all authentication services. Apologies for the late response.