# @devoxa/integresql-client 中文文档

规范地址：https://npmcn.com/package/%40devoxa/integresql-client/

版本：2\.1\.2
npm 元数据更新时间：2025-05-02T03:37:54.790Z
中文译文更新时间：2026-11-12T03:54:00.854Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40devoxa/integresql-client
原文对照：https://npmcn.com/package/%40devoxa/integresql-client/?lang=original
源码仓库：https://github.com/devoxa/integresql-client

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

- 包体积（解压后）：235 kB，120 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：1 个
- 首次发布：2023-02-04T04:27:01.648Z
- 最新版本发布：2025-05-02T03:37:54.554Z
- 近 30 天下载量：68895（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

在集成测试中管理孤立的 PostgreSQL 数据库的IntegreSQL 客户端

## 安装

```sh
npm install @devoxa/integresql-client
```

也可以使用：`pnpm add @devoxa/integresql-client`、`yarn add @devoxa/integresql-client`、`bun add @devoxa/integresql-client`

## README

# integresql 客户端

#### [整合SQL](https://github.com/allaboutapps/integresql) 在集成测试中管理孤立的 PostgreSQL 数据库的客户端

 [![Package Version](https://img.shields.io/npm/v/@devoxa/integresql-client?style=flat-square)](https://www.npmjs.com/package/@devoxa/integresql-client)[![Build Status](https://img.shields.io/github/actions/workflow/status/devoxa/integresql-client/push.yml?branch=master&style=flat-square) ](https://github.com/devoxa/integresql-client/actions?query=branch%3Amaster+workflow%3A%22Continuous+Integration%22)[![Code Coverage](https://img.shields.io/codecov/c/github/devoxa/integresql-client/master?style=flat-square)](https://codecov.io/github/devoxa/integresql-client)

[安装](https://npmcn.com/package/%40devoxa/integresql-client/#readme-installation) 二. 支助 [使用量](https://npmcn.com/package/%40devoxa/integresql-client/#readme-usage) 二. 支助 [贡献者](https://npmcn.com/package/%40devoxa/integresql-client/#readme-contributors) 二. 支助 [许可证](https://npmcn.com/package/%40devoxa/integresql-client/#readme-license)

  

## 安装

```bash
yarn add --dev @devoxa/integresql-client
```

**要安装IntegreSQL, 请跟随他们 [安装指令](https://github.com/allaboutapps/integresql#usage)。 。 。 .**

## 使用量

### 完整实例

**举个例子,你看看 [融合测试](https://npmcn.com/package/%40devoxa/integresql-client/tests-integration/user.spec.ts)。 。 。 .**

### 分步指南

1.  **初始化 IntegreSQL 客户端**

```ts
import { IntegreSQLClient } from '@devoxa/integresql-client'

const integreSQL = new IntegreSQLClient({ url: 'http://localhost:5000' })
// options.url: The URL of the IntegreSQL instance
```

2.  **(每一次试跑程序) 获取迁移设置的散列( T)**

```ts
// The hash can be generated in any way that fits your business logic, the included
// helper creates a SHA1 hash of the file content of all files matching the glob patterns.
const hash = await integreSQL.hashFiles(['./migrations/**/*', './fixtures/**/*'])
```

3.  **(每一次试跑程序) 初始化模板数据库**

```ts
await integreSQL.initializeTemplate(hash, async (databaseConfig) => {
  await migrateTemplateDatabase(databaseConfig)
  await seedTemplateDatabase(databaseConfig)
  await disconnectFromDatabase(databaseConfig)
})
```

4.  **(每次试验之前) 获取一个孤立的测试数据库**

```ts
const databaseConfig = await integreSQL.getTestDatabase(hash)
```

### 帮助者

-   `integreSQL.databaseConfigToConnectionUrl(databaseConfig)`
    -   将数据库配置对象转换为 a [连接 URL](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)

### API 请求

您可以直接通过包含的 API 客户端向 IntegreSQL 实例发送请求, 或者可选择 切换新的 [`IntegreSQLApiClient`](https://npmcn.com/package/%40devoxa/integresql-client/src/apiClient.ts) 你自己来.

```ts
await integreSQL.api.reuseTestDatabase(hash, id)

const api = new IntegreSQLApiClient({ url: 'http://localhost:5000' })
await api.reuseTestDatabase(hash, id)
```

## 贡献者

感谢这些伟大的人[emoji 密钥](https://allcontributors.org/docs/en/emoji-key):

<table><tbody><tr><td align="center"><a href="https://www.david-reess.de/" rel="nofollow noopener noreferrer"><img alt="David Reeß" src="https://avatars3.githubusercontent.com/u/4615516?v=4?s=75" width="75px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>大卫·瑞斯</b></sub></a><br><a href="https://github.com/devoxa/integresql-client/commits?author=queicherius" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/devoxa/integresql-client/commits?author=queicherius" title="Documentation" rel="nofollow noopener noreferrer">📖</a> <a href="https://github.com/devoxa/integresql-client/commits?author=queicherius" title="Tests" rel="nofollow noopener noreferrer">⚠️</a></td><td align="center"><a href="https://github.com/saratscheff" rel="nofollow noopener noreferrer"><img alt="Pedro Saratscheff" src="https://avatars.githubusercontent.com/u/4401263?v=4?s=75" width="75px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>佩德罗·萨拉特谢夫</b></sub></a><br><a href="https://github.com/devoxa/integresql-client/commits?author=saratscheff" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/devoxa/integresql-client/commits?author=saratscheff" title="Tests" rel="nofollow noopener noreferrer">⚠️</a></td></tr></tbody></table>

本项目遵循 [全部贡献者](https://github.com/all-contributors/all-contributors) 规格。 任何捐款都欢迎!

## 许可证

麻省理工学院

## 常见问题

### @devoxa/integresql-client 是什么？

在集成测试中管理孤立的 PostgreSQL 数据库的IntegreSQL 客户端

### 如何安装 @devoxa/integresql-client？

在项目目录运行 npm install @devoxa/integresql-client，或使用 pnpm add / yarn add / bun add。

### @devoxa/integresql-client 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/devoxa\_\_integresql-client 是否存在。

### @devoxa/integresql-client 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @devoxa/integresql-client 可以商用吗？

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

### @devoxa/integresql-client 的下载量有多少？

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

### @devoxa/integresql-client 还在维护吗？

最新版本 2\.1\.2 发布于 2025/05/02（1\.5 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/02/04。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

