@atscript/db-client

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

Browser-compatible HTTP client for @atscript/moost-db REST endpoints.

原始使用文档
文档目录5 节
  1. Installation
  2. Quick Start
  3. Features
  4. Documentation
  5. License

Atscript

@atscript/db-client

HTTP client for @atscript/moost-db REST endpoints.

Documentation · HTTP Client Guide


Type-safe HTTP client that mirrors moost-db controller endpoints. Works in browsers, Node.js, and any runtime with fetch. Each method maps 1:1 to a controller endpoint — filters, sorting, pagination, relation loading, text search, and aggregation are all supported through typed query controls.

In SSR environments, Moost's fetch automatically routes local requests to handlers in-process, so the same Client instance works on both server and browser.

Installation

pnpm add @atscript/db-client

Quick Start

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();

Features

  • Typed queries — filter keys, sort fields, $with relation names, and primary keys are type-checked against the Atscript model
  • Full CRUD — query, count, pages, one, insert, update, replace, remove
  • Aggregation — typed $groupBy dimensions and measures with inferred result types
  • Search — full-text and vector search via query controls
  • Client-side validation — validates writes against the Atscript schema before sending
  • Error handling — ClientError with structured validation errors
  • Configurable — custom fetch, static or async headers, base URL

Documentation

License

MIT

版本与发布记录

@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 是什么?

Browser-compatible HTTP client for @atscript/moost-db REST endpoints.

如何安装 @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 和提交记录判断。