Apps

Make a table private per user

Marks a table of the app's database as per-user: column holds the owner (the user's id, sub in x-hypamoon-user). From then on the app reads and writes it only with env.DB.mine(table) (select, get, count, insert, update, delete), always for the signed-in user; plain SQL that names the table is refused, and so are migrations that would read it around that (views, copies). admin_role lets users with that role use all rows with env.DB.mine(table, { all: true }). The app needs auth and database; the running version picks it up within seconds.

put/apps/{id}/tables/{table}/owner

Request

  • Base URL: https://api.hypamoon.com/api/v1
  • URL: https://api.hypamoon.com/api/v1/apps/{id}/tables/{table}/owner
  • Auth: one of:
    • HTTP bearer
    • OAuth 2 (authorization code, authorization URL https://app.hypamoon.com/oauth/authorize, token URL https://api.hypamoon.com/oauth/token, scopes: sites:write)

Path parameters

idstring uuid required

The id of the app.

tablestring required

The name of a table in the app's database.

Request body

columnstring

The column that holds the owner: the user's id (sub from x-hypamoon-user). Defaults to user_id. It must exist; make it TEXT NOT NULL with an index.

admin_rolestring nullable

Optional. A role of the app (like admin) whose users may use all rows with env.DB.mine(table, { all: true }). Leave it out and nobody sees other users' rows, admins included.

Response

The app, with database.per_user_tables.

idstring uuid required
namestring required
site_idstring uuid required
urlstring required

The site; the app answers on url + /api.

api_urlstring required

Where the app's /api starts.

mode'live' | 'test' required
status'active' | 'offline' required

offline: Hypamoon took the site offline; the app does not run.

versioninteger required

The version that runs now.

allowed_hostsstring[] required
secretsstring[] required
keptstring[]

Only in the answer to a deploy of an existing app: the settings that were left out and kept from the running version, like "allowed_hosts (20)", "vars (2)", "database", "auth".

warningsstring[]

Only in the answer to a deploy: advice about the app's data, never a block. For example that export and delete per user won't cover the data (no table marked with set_table_owner_column), or tables that look like backups or copies. Tell the user in plain words and offer to fix it.

created_atstring required
updated_atstring required

Changes

No recorded changes to this operation across all 1 revision of this API.