@morphql/store

中文文档
0.1.47发布于 2026/11/02MITTypeScriptESM + CJS构建来源已验证

In-memory and persistent data store for morphql with SQL-like query support.

原始使用文档
文档目录7 节
  1. Key Features
  2. Installation
  3. Usage
  4. In-memory store
  5. Persistent folder store (Node.js)
  6. Learn More
  7. License

MorphQL

npm version License: MIT

@morphql/store

A lightweight data store for MorphQL with a familiar SQL-like query interface. SELECT, INSERT, UPDATE, and DELETE statements are transpiled to MorphQL and executed against pluggable storage adapters.

Key Features

  • 🗂️ SQL-like API: Query and mutate data with SELECT, INSERT, UPDATE, DELETE.
  • 🔌 Pluggable Adapters: In-memory adapter for tests and runtime data, folder adapter for JSON-on-disk persistence.
  • 🚀 Powered by MorphQL: Statements are transpiled to MorphQL and compiled to native JS for fast execution.
  • 🔢 Autoincrement: Built-in auto() / $auto placeholders for numeric primary keys.
  • 🌐 Isomorphic Core: The in-memory adapter runs in both Node.js and the browser; the folder adapter is Node-only.

Installation

npm install @morphql/store

Usage

In-memory store

import { Store, MemoryAdapter } from '@morphql/store';

const store = new Store(new MemoryAdapter());

await store.query(`INSERT INTO users (id, name, age) VALUES (auto(), 'Alice', 30)`);
await store.query(`INSERT INTO users (id, name, age) VALUES (auto(), 'Bob', 17)`);

const adults = await store.query(`SELECT name FROM users WHERE age >= 18`);
// → [{ name: 'Alice' }]

Persistent folder store (Node.js)

import { Store } from '@morphql/store';
import { FolderAdapter } from '@morphql/store/node';

const store = new Store(new FolderAdapter('./data', { pretty: true }));

await store.query(`UPDATE users SET status = 'active' WHERE age >= 18`);

Each table is persisted as a JSON file inside the directory (e.g. ./data/users.json).

Learn More

License

MIT

版本与发布记录

@morphql/store 共发布 8 个版本,首次发布于 2026/05/19;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.47latest2026/11/021 天前
0.1.462026/07/283 个月前
0.1.452026/05/275 个月前
0.1.442026/05/275 个月前
0.1.432026/05/215 个月前
0.1.422026/05/195 个月前

关于 @morphql/store 的常见问题

@morphql/store 是什么?

morphql的内存和持久数据存储,具有类似sql的查询支持。

如何安装 @morphql/store?

在项目目录运行 npm install @morphql/store,或使用 pnpm add / yarn add / bun add。

@morphql/store 支持 TypeScript 吗?

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

@morphql/store 支持 ESM 还是 CommonJS?

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

@morphql/store 可以商用吗?

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

@morphql/store 还在维护吗?

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