@0q/embedded-mongodb

中文文档
0.1.1发布于 2026/09/08SSPL-1.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 6559

Run the MongoDB Node.js driver against an in-process embedded MongoDB engine

原始使用文档

@0q/embedded-mongodb

The MongoDB Node.js driver over an embedded MongoDB engine: the real server code, running inside your process against a local directory. No server, no port.

const { MongoClient } = require('@0q/embedded-mongodb');

const client = new MongoClient('mongodb_embedded://./data');
const items = client.db('app').collection('items');
await items.insertOne({ name: 'embedded' });
console.log(await items.findOne());
await client.close();

MongoClient is the driver's own class with one addition: a mongodb_embedded://<directory> (or mongodb+embedded://) address opens the directory in-process instead of connecting to a server. Any other address is handed to the driver untouched. The mongodb package is a peer dependency for this class; the lower layer needs nothing:

const { open } = require('@0q/embedded-mongodb');

const embedded = await open('./data');
// embedded.uri is a mongodb:// address any driver in this process can connect to.
await embedded.close();

Only one engine may be open per process. Linux x64, Linux arm64 and macOS arm64 are the supported platforms. Authentication, TLS, compression, sessions, transactions and change streams are not supported.

Part of embedded-mongo, which has the full documentation, the Python binding and the engine itself. Licensed under the SSPL-1.0, as MongoDB is.

版本与发布记录

@0q/embedded-mongodb 共发布 2 个版本,首次发布于 2026/09/08;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.1latest2026/09/081 个月前
0.1.02026/09/081 个月前

关于 @0q/embedded-mongodb 的常见问题

@0q/embedded-mongodb 是什么?

Run the MongoDB Node.js driver against an in-process embedded MongoDB engine

如何安装 @0q/embedded-mongodb?

在项目目录运行 npm install @0q/embedded-mongodb,或使用 pnpm add / yarn add / bun add。

@0q/embedded-mongodb 支持 TypeScript 吗?

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

@0q/embedded-mongodb 支持 ESM 还是 CommonJS?

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

@0q/embedded-mongodb 需要什么版本的 Node.js?

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

@0q/embedded-mongodb 可以商用吗?

@0q/embedded-mongodb 使用 SSPL-1.0 许可。声明的许可为 SSPL-1.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@0q/embedded-mongodb 的下载量有多少?

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

@0q/embedded-mongodb 还在维护吗?

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