@apostrophecms/emulate-mongo-3-driver

中文文档
1.0.7发布于 2026/07/11MITCommonJS近 30 天下载 7810

Emulate the Mongo 3.x nodejs driver on top of the Mongo 6.x nodejs driver, for bc

原始使用文档
文档目录4 节
  1. Purpose
  2. Usage
  3. Goals
  4. What about those warnings?

@apostrophecms/emulate-mongo-3-driver

Purpose

You have legacy code that depends on the 3.x version of the MongoDB Node.js driver. You don't want to upgrade to the 6.x driver because of backwards compability problems in v4, v5, v6 but you don't have a choice because of reported vulnerabilities such as those detected by npm audit.

@apostrophecms/emulate-mongo-3-driver aims to be a compatible emulation of the 3.x version of the MongoDB Node.js driver, implemented as a wrapper for the 6.x driver.

It was created for long term support of ApostropheCMS. Of course, ApostropheCMS 3.x and 4.x will use the MongoDB 6.x driver directly.

Usage

If you are using ApostropheCMS, this is standard beginning with versions 3.64.0+ and 4.2.0+. You don't have to do anything.

The example below is for those who wish to use this driver in non-ApostropheCMS projects.

npm install @apostrophecms/emulate-mongo-3-driver
const mongo = require('@apostrophecms/emulate-mongo-3-driver');

// Use it here as if it were the 3.x driver

Goals

This module aims for partial compatibility with the features mentioned as obsolete or changed in v4, v5, v6 but there are omissions.

An emphasis has been placed on features used by ApostropheCMS but PRs for further compatibility are welcome.

What about those warnings?

"What about the warnings re: insert, update and ensureIndex operations being obsolete?"

Although deprecated, some of these operations are still supported by the 6.x driver and work just fine.

However, since the preferred newer operations were also supported by the 3.x driver, the path forward is clear.

We will migrate away from using them gradually, and you should do the same.

It doesn't make sense to provide "deprecation-free" wrappers when doing the right thing is in easy reach.

版本与发布记录

@apostrophecms/emulate-mongo-3-driver 共发布 8 个版本,首次发布于 2024/04/16;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.7latest2026/07/113 个月前
1.0.62024/07/202 年前
1.0.52024/07/092 年前
1.0.42024/07/052 年前
1.0.32024/06/292 年前
1.0.22024/04/182 年前

关于 @apostrophecms/emulate-mongo-3-driver 的常见问题

@apostrophecms/emulate-mongo-3-driver 是什么?

Emulate the Mongo 3.x nodejs driver on top of the Mongo 6.x nodejs driver, for bc

如何安装 @apostrophecms/emulate-mongo-3-driver?

在项目目录运行 npm install @apostrophecms/emulate-mongo-3-driver,或使用 pnpm add / yarn add / bun add。

@apostrophecms/emulate-mongo-3-driver 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/apostrophecms__emulate-mongo-3-driver 是否存在。

@apostrophecms/emulate-mongo-3-driver 支持 ESM 还是 CommonJS?

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

@apostrophecms/emulate-mongo-3-driver 可以商用吗?

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

@apostrophecms/emulate-mongo-3-driver 的下载量有多少?

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

@apostrophecms/emulate-mongo-3-driver 还在维护吗?

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