@atscript/db-client

中文文档
0.1.174发布于 2026/11/07MITTypeScriptESM + CJS近 30 天下载 4009

为@atscript/moost-db REST 端点浏览兼容的 HTTP 客户端 .

中文使用文档
文档目录5 节
  1. 安装
  2. 快速启动
  3. 特征
  4. 文档
  5. 许可证

Atscript

@ atscript/ db- 客户端

HTTP 客户端 @atscript/moost-db REST终点.

文档 • 妇女 HTTP 客户指南


Type-safe HTTP客户端,可以镜像moost-db控制器端点. 在浏览器、节点和任何运行时间中工作 fetch。每种方法将 1:1 映射到一个控制器端点—— 过滤器、排序、页码、关系加载、文本搜索和汇总都通过打入的查询控制得到支持.

在苏维埃社会主义共和国的环境下,Moost fetch 自动引导本地请求到进程内处理者, 所以相同 Client 实例在服务器和浏览器上都有效.

安装

pnpm add @atscript/db-client

快速启动

import { Client } from "@atscript/db-client";
import type { User } from "./models/user.as";

const users = new Client<typeof User>("/api/users", {
  baseUrl: "https://api.example.com",
});

// Query                            → GET /query
const active = await users.query({ filter: { status: "active" } });

// Get one                          → GET /one/:id
const user = await users.one("abc-123");

// Insert                           → POST /
const { insertedId } = await users.insert({ name: "Alice" });

// Update                           → PATCH /
await users.update({ id: insertedId, role: "admin" });

// Remove                           → DELETE /:id
await users.remove(insertedId);

// Count                            → GET /query ($count)
const total = await users.count();

// Paginate                         → GET /pages
const page = await users.pages({ filter: { active: true } }, 1, 20);

// Metadata                         → GET /meta
const meta = await users.meta();

特征

  • 输入的查询 ——过滤键,排序字段, $with 关系名称,主密钥会对照标记模式进行类型检查
  • 完整 CRUD —— 说 query, (中文(简体) ), count, (中文(简体) ), pages, (中文(简体) ), one, (中文(简体) ), insert, (中文(简体) ), update, (中文(简体) ), replace, (中文(简体) ), remove
  • 合计 — 已输入 $groupBy 数量和措施,包括推断结果类型
  • 搜索 ——通过查询控制进行全文和矢量搜索
  • 客户端验证 ——在发送前将验证书写在标注图上
  • 处理错误 —— 说 ClientError 有结构化验证错误
  • 可配置 - 习惯 fetch,静态或同步头,基址

文档

许可证

麻省理工学院

版本与发布记录

@atscript/db-client 共发布 132 个版本,首次发布于 2026/03/21;过去 12 个月发布了 132 个版本。

版本发布日期距今
0.1.174latest2026/11/07今天
0.1.1732026/11/071 天前
0.1.1722026/11/061 天前
0.1.1712026/11/061 天前
0.1.1702026/11/061 天前
0.1.1692026/11/043 天前

关于 @atscript/db-client 的常见问题

@atscript/db-client 是什么?

为@atscript/moost-db REST 端点浏览兼容的 HTTP 客户端 .

如何安装 @atscript/db-client?

在项目目录运行 npm install @atscript/db-client,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@atscript/db(^0.1.174)、@atscript/typescript(^0.2.9)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atscript/db-client 支持 TypeScript 吗?

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

@atscript/db-client 支持 ESM 还是 CommonJS?

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

@atscript/db-client 可以商用吗?

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

@atscript/db-client 的下载量有多少?

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

@atscript/db-client 还在维护吗?

最新版本 0.1.174 发布于 2026/11/07(今天);至今共发布 132 个版本,其中过去 12 个月发布了 132 个;首次发布于 2026/03/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。