# 快速开始 (/docs/cloud/services/database/quickstart)



在 Node.js 22 或更高版本中运行，将 develop API Key 放入 PRAXIS\_API\_KEY 环境变量。每次运行都会创建一个新库。

```bash
npm install @supabase/supabase-js
```

将下面内容保存为 `quickstart.mjs`，运行 `node quickstart.mjs`。

```javascript
import { createClient } from "@supabase/supabase-js";

const api = "https://api.deepraxis.ai";
const key = process.env.PRAXIS_API_KEY;
if (!key) throw new Error("Set PRAXIS_API_KEY");

async function request(path, method, body) {
  const response = await fetch(`${api}/database/v1${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${key}`,
      "Content-Type": "application/json",
    },
    ...(body === undefined ? {} : { body: JSON.stringify(body) }),
  });
  const result = await response.json();
  if (!response.ok) throw new Error(`${response.status}: ${result.message}`);
  return result;
}

const database = await request("/databases", "POST", {
  name: "Agent tasks",
  labels: { purpose: "docs" },
});
await request(`/databases/${database.id}/tables`, "POST", {
  name: "tasks",
  fields: [
    { name: "title", type: "string", required: true, unique: true },
    { name: "done", type: "boolean" },
  ],
});

const supabase = createClient(`${api}/supabase/${database.id}/`, key, {
  auth: { persistSession: false, autoRefreshToken: false },
});

const inserted = await supabase.from("tasks")
  .insert({ title: "Write a summary", done: false }).select();
if (inserted.error) throw inserted.error;

const selected = await supabase.from("tasks")
  .select("*").order("title").limit(10);
if (selected.error) throw selected.error;
console.log({ database_id: database.id, rows: selected.data });
```

输出包含 `database_id` 和刚写入的行。保存库 ID 供后续请求使用。Supabase 地址末尾的斜杠不可省略。

[继续更新与删除行 →](/docs/api/compatible/supabase/tables) · [理解字段与版本 →](/docs/cloud/services/database/concepts)

用完后，可用下面的请求删除示例库。恢复规则见[概念](/docs/cloud/services/database/concepts)。

```bash
curl -X DELETE "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
```

将 `DATABASE_ID` 设为示例输出的库 ID。
