@atscript/moost-db

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

Generic database controller for Moost with Atscript.

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

Atscript

@atscript/moost-db

Define your models once — get TypeScript types, runtime validation, and DB metadata from a single .as model.

Documentation · HTTP API Guide


Generic database controller for the Moost framework. Exposes Atscript-defined database tables and views as RESTful HTTP endpoints with zero boilerplate. Works with any @atscript/db adapter (SQLite, PostgreSQL, MongoDB, MySQL).

Installation

pnpm add @atscript/moost-db

Peer dependencies: moost, @moostjs/event-http, @wooksjs/http-body, @atscript/db, @atscript/typescript.

@wooksjs/http-body is required by the @DbActionID / @DbActionIDs parameter resolvers (used by the action layer) to read the parsed JSON request body.

Quick Start

import { AsDbController, TableController } from "@atscript/moost-db";
import { User } from "./models/user.as";

@TableController(usersTable)
export class UsersController extends AsDbController<typeof User> {}

This gives you: GET /query, GET /pages, GET /one/:id, POST /, PUT /, PATCH /, DELETE /:id, GET /meta.

Features

  • Full CRUD via AsDbController — insert, replace, update, delete (single and batch)
  • Read-only via AsDbReadableController — query, paginate, get-one for views
  • URL query syntax — filtering, sorting, pagination, field selection via query strings
  • Relation loading with $with — eagerly load related data
  • Text search ($search) and vector search ($vector) with pluggable computeEmbedding() hook
  • Aggregation with $groupBy
  • Overridable hooks — onWrite, onRemove, transformFilter, computeEmbedding
  • Decorator shortcuts: @TableController, @ReadableController, @ViewController

Documentation

License

MIT

版本与发布记录

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

版本发布日期距今
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/moost-db 的常见问题

@atscript/moost-db 是什么?

Generic database controller for Moost with Atscript.

如何安装 @atscript/moost-db?

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

@atscript/moost-db 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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