See live database data
flow end to end

A real PloyDB table, a server-side API request, and the rendered response on one inspectable page.

Request flow

What happens when this page loads

1. Records live in PloyDB

The database stores three typed rows in the Demo tasks table.

2. Astro runs on the server

The route calls the PloyDB client for every page request. This page is not prerendered.

3. The gateway checks access

A read-only token is loaded from a server secret and scoped to this table.

4. Friendly rows render

The client maps field IDs into title, description, status, and priority properties.

Live response

Rows fetched from Demo tasks

Edit a record in PloyDB, then refresh this route. The page reads the new value without copying rows into source files.

3 records returned
DonePriority 1

Verify the database connection

Confirm that the server-side page can read live PloyDB records.

row_3aa41db98f54f528b8e8

In progressPriority 2

Render records on the page

Map immutable field IDs to friendly names before rendering.

row_a01f4d8ada4a8741c5f8

ReadyPriority 3

Edit a row in PloyDB

Change this record later to prove the page updates without code changes.

row_6475f304387938f1fa12

Under the hood

The actual request contract

IDs are safe to keep in source. The bearer token is not. The route imports the client only in Astro server code, so the browser never receives the secret.

Database ID
pdb_4d6ad9f9ad0e462eb5a2
Table ID
tbl_c45281dd298a470cae89
Secret name
PLOYDB_DEMO_READ_TOKEN

HTTP request

POST ${PLOYDB_GATEWAY_URL}/site/v1/ploydbs/pdb_4d6ad9f9ad0e462eb5a2/tables/tbl_c45281dd298a470cae89/query
Authorization: Bearer <server-only token>
Content-Type: application/json

{
  "sort": [{ "field": "fld_6535910fb4444790", "dir": "asc" }],
  "limit": 10
}

Field mapping

titlefld_5e27a8a6d8a5489a
descriptionfld_ba65b0d9fc2e4853
statusfld_c11d1fb52fa94147
priorityfld_6535910fb4444790

Route code

const { rows, error } = await demoDb.queryRowsResult(
  DEMO_TASKS_TABLE,
  DEMO_TASK_FIELDS,
  {
    sort: [{ field: DEMO_TASK_FIELDS.priority, dir: "asc" }],
    limit: 10,
  },
  PREVIEW_DEMO_TASKS,
);

Test the live flow

Open PloyDB, choose PloyDB Runtime Demo, edit any Demo tasks row, save it, and refresh this page. No page code or rebuild is needed for the data change.

Return to live records