@getanthill/datastore

中文文档
0.95.6发布于 2026/01/16MITTypeScriptCommonJS近 30 天下载 2554

Event-Sourced Datastore

原始使用文档
文档目录11 节
  1. 🎯 Purpose
  2. 📚 Documentation
  3. ✨ Key Features
  4. 💻 Command Line Interface (CLI)
  5. CLI Features
  6. 💿 Installation
  7. 🚀 Usage Examples
  8. Running the API Server
  9. Using the CLI
  10. 🤝 Contributing
  11. 🙏 Acknowledgements

getanthill Datastore

pipeline Quality Gate Status

Coverage Security Rating Reliability Rating

Docker pulls npm downloads

🎯 Purpose

The goal of this project is to provide a system to easily access the full power of Event-Source / CQRS systems.

📚 Documentation

https://datastore.getanthill.org/

✨ Key Features

The getanthill Datastore is engineered to empower developers with a robust, scalable, and highly observable data management system built on modern architectural patterns.

CQRS & Event Sourcing: At its core, the Datastore fully embraces Command Query Responsibility Segregation (CQRS) and Event Sourcing. Manage every data entity as an immutable event stream, enabling precise atomic updates, historical reconstruction of entities to any past state, and advanced "time-travel" debugging.

Contract-First Development with JSON Schema: All data models within the Datastore are rigorously contractualized using the JSON Schema standard. This ensures data integrity and provides a strict, machine-readable contract for every piece of information, forming the foundation for reliable API interactions and event processing.

OpenAPI 3.0 Compliant API & Automatic Documentation: Leveraging its JSON Schema contracts, the Datastore automatically generates an OpenAPI 3.0 (formerly Swagger) specification. This provides comprehensive, up-to-date, and interactive documentation for your RESTful API, simplifying integration and ensuring clarity for all consumers.

Real-time Data Streaming: Process data in real-time with an integrated stream API entrypoint. Deploy workers with automatic reconnection capabilities, robust pattern matching, and built-in logging, enabling immediate reactions to data changes.

Flexible Message Broker Integration: The Datastore offers seamless integration with popular message brokers such as MQTT and RabbitMQ (AMQP). This allows for flexible event distribution, enabling advanced asynchronous communication patterns and microservices architectures.

Fine-grained Access Control: Secure your data with a comprehensive role-based access control system. Four distinct access levels (READ, DECRYPT, WRITE, ADMIN) allow for granular permissions, protecting sensitive information and operations.

Data Encryption: Easily encrypt sensitive fields within your data, providing robust data security. The system supports multiple keys, key rotation, and on-demand document encryption, ensuring data privacy even at rest.

Advanced Data Aggregation & Projections: Chain complex data projections and aggregations across multiple Datastore instances. This powerful pipeline enables sophisticated business logic, data transformation, and event tracking, facilitating advanced analytics and reporting.

Configurable & Observable: Tailor the Datastore to your needs with flexible configuration options for security, OpenAPI behavior, and feature enablement. Integrated telemetry and logging provide deep insights into system operations, simplifying monitoring and debugging.

💻 Command Line Interface (CLI)

The Datastore provides a powerful Command Line Interface for managing various aspects of your data and system.

CLI Features

  • Datastore Management: Interact with different datastore instances, configured via DATASTORE_CONFIGS environment variable.
  • Data Operations: Perform CRUD operations on your data models.
  • Model Handling: Manage and inspect data models, which are contractualized using json-schema.
  • Security: Configure and manage security-related aspects.
  • Event Streaming: Stream entities changes or events from different connectors (e.g., HTTP, AMQP) and synchronize them to other datastores.
  • Interactive Shell: Utilize an interactive run command for executing CLI commands in a persistent session, complete with command history and auto-completion.
  • Heartbeat Check: Verify the availability of datastore services.

💿 Installation

To get started with the getanthill Datastore, follow these steps:

  1. Clone the repository:

    git clone https://gitlab.com/getanthill/datastore.git
    cd datastore
    
  2. Install dependencies:

    npm install
    
  3. Environment Variables: Create a .env file in the root directory and configure necessary environment variables. Example:

    DATASTORE_API_URL=http://localhost:3001
    DATASTORE_ACCESS_TOKEN=your_secret_token
    
  4. Run the Datastore:

    npm start
    

🚀 Usage Examples

Running the API Server

npm start

The API will be available at http://localhost:3001 (or your configured DATASTORE_API_URL).

Using the CLI

Interactive Shell:

npm run cli run

Stream Events:

npm run cli stream <model> <source> -- --datastore default --output entity --connector http

Check Heartbeat:

npm run cli heartbeat

🤝 Contributing

We welcome contributions from the community! To contribute to the getanthill Datastore, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature-name or bugfix/your-bugfix-name.
  3. Make your changes and commit them: Follow our commit message guidelines.
  4. Push to your fork and open a Pull Request.

Please ensure your code adheres to our coding standards and passes all tests.

🙏 Acknowledgements

  • Thanks to all the contributors who have helped make this project better!
  • Special thanks to the open-source community for their invaluable tools and inspiration.

版本与发布记录

@getanthill/datastore 共发布 446 个版本,首次发布于 2020/11/26;过去 12 个月发布了 13 个版本。

版本发布日期距今
0.95.6latest2026/01/169 个月前
0.95.42025/12/0811 个月前
0.95.32025/11/2911 个月前
0.95.22025/11/2911 个月前
0.95.12025/11/2811 个月前
0.95.02025/11/2811 个月前

关于 @getanthill/datastore 的常见问题

@getanthill/datastore 是什么?

Event-Sourced Datastore

如何安装 @getanthill/datastore?

在项目目录运行 npm install @getanthill/datastore,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@getanthill/telemetry(1.12.1)、@shelf/jest-mongodb(4.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 datastore、ds,可以用 npx datastore 直接运行。

@getanthill/datastore 支持 TypeScript 吗?

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

@getanthill/datastore 支持 ESM 还是 CommonJS?

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

@getanthill/datastore 需要什么版本的 Node.js?

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

@getanthill/datastore 可以商用吗?

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

@getanthill/datastore 的下载量有多少?

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

@getanthill/datastore 还在维护吗?

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