# @axiom-lattice/pg-stores 中文文档

规范地址：https://npmcn.com/package/%40axiom-lattice/pg-stores/

版本：5\.0\.3
npm 元数据更新时间：2026-11-03T03:43:54.245Z
中文译文更新时间：2026-11-07T16:50:06.019Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40axiom-lattice/pg-stores
原文对照：https://npmcn.com/package/%40axiom-lattice/pg-stores/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：4.6 MB，212 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=20\.10\.0
- 运行依赖：7 个
- 首次发布：2026-01-07T16:37:24.327Z
- 最新版本发布：2026-11-03T03:43:54.067Z
- 近 30 天下载量：4428（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：159（近 12 个月 159 个）

## 中文简介

Axiom Lattice 框架的 PG 存储执行

## 安装

```sh
npm install @axiom-lattice/pg-stores
```

也可以使用：`pnpm add @axiom-lattice/pg-stores`、`yarn add @axiom-lattice/pg-stores`、`bun add @axiom-lattice/pg-stores`

## README

# @axiom-lattice/ pg- stores (英语)

PostgreSQL 为Axiom Lattice框架存储执行.

## 快速启动

```typescript
import { configureStores } from "@axiom-lattice/core";
import { createPgStoreConfig } from "@axiom-lattice/pg-stores";
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";

// One connection string creates all PG stores
const stores = createPgStoreConfig(process.env.DATABASE_URL);

// Register all stores in one call
await configureStores({
  ...stores,
  checkpoint: PostgresSaver.fromConnString(process.env.DATABASE_URL),
});
```

## `createPgStoreConfig`

从单一连接字符串创建所有 PG 存储实例的工厂函数 。 返回一个可扩展到 `configureStores()`。 。 。 .

```typescript
function createPgStoreConfig(connectionString: string): {
  workspace: PostgreSQLWorkspaceStore;
  project: PostgreSQLProjectStore;
  eval: PostgreSQLEvalStore;
  user: PostgreSQLUserStore;
  tenant: PostgreSQLTenantStore;
  userTenantLink: PostgreSQLUserTenantLinkStore;
  channelBinding: ChannelBindingStore;
  channelInstallation: PostgreSQLChannelInstallationStore;
  thread: PostgreSQLThreadStore;
  database: PostgreSQLDatabaseConfigStore;
  metrics: PostgreSQLMetricsServerConfigStore;
  mcp: PostgreSQLMcpServerConfigStore;
  assistant: PostgreSQLAssistantStore;
  workflowTracking: PostgreSQLWorkflowTrackingStore;
  threadMessageQueue: ThreadMessageQueueStore;
  schedule: PostgreSQLScheduleStorage;
}
```

存储于 `autoMigrate: true`: eval, 频道Binding, 频道安装, 工作流程跟踪, 线程MessageQuue. 其他人都会用 `autoMigrate: false` (手语: `initialize()` 通过 `configureStores`) (中文(简体) ).

## 个人存储使用

如果您只需要特定的商店, 请直接构建它们 :

```typescript
import { configureStores } from "@axiom-lattice/core";
import { PostgreSQLThreadStore, PostgreSQLAssistantStore } from "@axiom-lattice/pg-stores";

await configureStores({
  thread: new PostgreSQLThreadStore({ poolConfig: process.env.DATABASE_URL }),
  assistant: new PostgreSQLAssistantStore({ poolConfig: process.env.DATABASE_URL }),
});
```

## 可用存储

| 存储 | 类 | 说明 |
| --- | --- | --- |
| 线程 | `PostgreSQLThreadStore` | 线索 CRUD |
| 助理人员 | `PostgreSQLAssistantStore` | 助理CRUD |
| 技能 | `PostgreSQLSkillStore` | 技能存储 |
| 工作空间 | `PostgreSQLWorkspaceStore` | 工作空间管理 |
| 项目 | `PostgreSQLProjectStore` | 项目管理 |
| 数据库 | `PostgreSQLDatabaseConfigStore` | DB 连接配置 |
| 计量 | `PostgreSQLMetricsServerConfigStore` | 计量服务器配置 |
| 微调 | `PostgreSQLMcpServerConfigStore` | MCP 服务器配置 |
| 用户 | `PostgreSQLUserStore` | 用户存储 |
| 租户 | `PostgreSQLTenantStore` | 租户存储 |
| 用户 TenantLink | `PostgreSQLUserTenantLinkStore` | 用户租户链接 |
| 线程信息队列 | `ThreadMessageQueueStore` | 信件队列持续性 |
| 工作流程跟踪 | `PostgreSQLWorkflowTrackingStore` | 工作流程运行跟踪 |
| eval (中文) | `PostgreSQLEvalStore` | 评价存储 |
| 频道安装 | `PostgreSQLChannelInstallationStore` | 频道装置 |
| 频道编辑 | `ChannelBindingStore` | 发件人对代理绑定 |
| 时间表 | `PostgreSQLScheduleStorage` | 排定的任务持久性 |

## 构造选项

所有商店都接受相同的选项模式 :

```typescript
interface StoreOptions {
  poolConfig: string | PoolConfig;  // Connection string or PoolConfig object
  autoMigrate?: boolean;            // Run migrations automatically (default: true)
}
```

## 移徙系统

每个商店管理自己的计划迁移 `MigrationManager`. 期间的移徙 `initialize()`。 。 。 .

```typescript
// Manual control
const store = new PostgreSQLThreadStore({
  poolConfig: process.env.DATABASE_URL,
  autoMigrate: false,
});
await store.initialize(); // Migrations applied here
```

## 常见问题

### @axiom-lattice/pg-stores 是什么？

Axiom Lattice 框架的 PG 存储执行

### 如何安装 @axiom-lattice/pg-stores？

在项目目录运行 npm install @axiom-lattice/pg-stores，或使用 pnpm add / yarn add / bun add。

### @axiom-lattice/pg-stores 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @axiom-lattice/pg-stores 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @axiom-lattice/pg-stores 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=20\.10\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @axiom-lattice/pg-stores 可以商用吗？

@axiom-lattice/pg-stores 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @axiom-lattice/pg-stores 的下载量有多少？

根据 npm 官方下载统计，@axiom-lattice/pg-stores 在 2026/10/08 – 2026/11/06 这 30 天内被下载 4,428 次，日均约 148 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @axiom-lattice/pg-stores 还在维护吗？

最新版本 5\.0\.3 发布于 2026/11/03（4 天前）；至今共发布 159 个版本，其中过去 12 个月发布了 159 个；首次发布于 2026/01/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

