跳到内容
光环标志
光环基地

数据库

Database 产品为项目提供了什么、代码如何访问它,以及接下来该读什么:入门、概念和任务指南。

说明4分钟 读取级别 初学者

自此翻译以来,英文来源已发生变化。某些信息可能已过时。
该页面已自动翻译。英文版具有权威性。

What you get#

Each project has its own PostgreSQL 18 database. Your tables live in one schema of that database, named after the project, and the platform keeps its own data (users, files, settings) in separate schemas that your code does not reach.

aura db raw "select current_setting('server_version_num')::int / 10000 as postgres_major"
  postgres_major
  ──────────────
  18

  ℹ 1 row(s).
  • Row level security by default. Every table created through Aurabase (SDK table API, aura db raw, migrations, the Studio) gets row level security enabled. Until you add a policy, the public key reads no row.
  • Plain PostgreSQL. Views, functions, triggers, indexes and policies are standard PostgreSQL objects. Thirteen extensions are installed when a project is created on the cluster of its organization, and pg_graphql is installed when you enable GraphQL.
  • Isolated by role. Each kind of caller reaches PostgreSQL as a different role: aura_anon for the public key, aura_authenticated for a signed-in user, a role that bypasses RLS for the service_role key. Policies read the user from auth.uid().
  • Branches. aura branch create copies a project, schema and rows, into a new project with its own URL and keys. It is a copy made at creation time, not a live replica.

Three ways in#

Browser, server   ──▶  SDK or REST  ──▶  gateway  ──▶  PostgREST of the project  ──▶  PostgreSQL
CLI, backend, CI  ──▶  aura db raw  ──▶  gateway  ──▶  aura-db (SQL check)       ──▶  PostgreSQL
psql, ORM, BI     ──▶  TLS :5432    ──▶  router   ──▶  pooler of the cluster      ──▶  PostgreSQL

The first path is the one your application uses. The second runs SQL with the service_role key, after a check that refuses a list of statements. The third is a plain PostgreSQL connection with a role of its own. How a request reaches Postgres follows each path step by step.

Start here#

Concepts#

Guides and reference#

In the Studio#

The Database section of a project opens the table editor of a PostgreSQL project, or the collections of a MongoDB project. Its pages:

/<project-id>/database                     opens the table editor (PostgreSQL) or the collections (MongoDB)
/<project-id>/database/sql/table-editor    browse and edit rows, create tables and columns
/<project-id>/database/sql/editor          SQL editor (the same endpoint as aura db raw)
/<project-id>/database/sql/schema          tables, views and functions of the project schema
/<project-id>/database/extensions          installed extensions
/<project-id>/database/backups             backups and restores

The direct connection card (host, role, password) is under Settings › Connection, and the API keys under Settings › API keys.

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ 报告问题