OpenThink Cloud

Request context and data access

Read the caller, the project's tables, secrets and other functions from c.var.think.

Every handler receives c.var.think with the following fields.

FieldDescription
viewerThe caller { id, name, email, image }, verified by OpenThink IAM. null for guests on public routes.
viaHow the call arrived: "http", "html" (think.call), "mcp", "cron" or "table".
storeThe project's tables, addressed by table and column name. See below.
secretsSecrets of the service account, for example secrets.STRIPE_KEY.
call(name, args)Call a Function of the project.
space{ id } of the project.
service{ version, name, account }.

Reading and writing tables

js
const task = await store.get("Tasks", id)               // row or null
const open = await store.list("Tasks", {
  where: { Status: "Todo" }, orderBy: "-Due", limit: 50, offset: 0,
})
const row = await store.insert("Tasks", { Title: "Write docs" }) // { _id, ... }
const n = await store.update("Tasks", id, { Status: "Done" })    // rows changed
await store.delete("Tasks", id)

const rows = await store.sql('SELECT "Title" FROM "Tasks" WHERE "Status" = ?', ["Todo"])
const res = await store.query("UPDATE ...", [])  // { columns, rows, inserted, updated, deleted, changes }

Every row has a hidden _id column.

Service account or caller

By default store runs as the service account of the project: it reads and writes every table the account can access and is not limited by table policies. Rows it inserts record the service name as their creator.

store.asViewer() exposes the same methods but runs as the caller, under their role and the table's policies:

  • Reads return only rows the caller may see.
  • Writes outside the policy throw an error.
  • Updating a row the caller cannot see behaves as if no row matched (update returns 0).
  • Inserted rows record the caller as creator.

Outbound requests and logs

  • fetch() to external services works, up to 50 subrequests per call.
  • console.* output is attached to the call in the logs.

Last updated 2026-12-03 UTC. Something wrong or missing? Send feedback.