# @apostrophecms/emulate-mongo-3-driver

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

Latest version **1.0.7** (published 2026-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @apostrophecms/emulate-mongo-3-driver
pnpm add @apostrophecms/emulate-mongo-3-driver
yarn add @apostrophecms/emulate-mongo-3-driver
bun add @apostrophecms/emulate-mongo-3-driver
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2026-07-10 |
| First published | 2024-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 48.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4639 |
| Author | Apostrophe Technologies |
| Maintainers | alexgilbert, boutell, romanek, bodonkey |
| Keywords | mongodb, mongo, apostrophecms |

## Links

- npm: https://www.npmjs.com/package/@apostrophecms/emulate-mongo-3-driver
- Repository: https://github.com/apostrophecms/apostrophe
- Homepage: https://github.com/apostrophecms/apostrophe/tree/main/packages/emulate-mongo-3-driver#readme
- Issues: https://github.com/apostrophecms/emulate-mongo-3-driver/issues
- npm.io page: https://npm.io/package/@apostrophecms/emulate-mongo-3-driver

## Dependencies (2)

- [mongodb](https://npm.io/package/mongodb.md) ^6.8.0
- [mongodb-legacy](https://npm.io/package/mongodb-legacy.md) ^6.0.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.7 (latest) — 2026-07-10
- 1.0.6 — 2024-07-19
- 1.0.5 — 2024-07-09
- 1.0.4 — 2024-07-04
- 1.0.3 — 2024-06-28
- 1.0.2 — 2024-04-18
- 1.0.1 — 2024-04-17
- 1.0.0 — 2024-04-16

## README

# @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](https://github.com/mongodb/node-mongodb-native/blob/v6.0.0/etc/notes/CHANGES_4.0.0.md),
[v5](https://github.com/mongodb/node-mongodb-native/blob/v6.0.0/etc/notes/CHANGES_5.0.0.md),
[v6](https://github.com/mongodb/node-mongodb-native/blob/v6.0.0/etc/notes/CHANGES_6.0.0.md)
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](https://apostrophecms.com).
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.

```sh
npm install @apostrophecms/emulate-mongo-3-driver
```

```javascript
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](https://github.com/mongodb/node-mongodb-native/blob/v6.0.0/etc/notes/CHANGES_4.0.0.md),
[v5](https://github.com/mongodb/node-mongodb-native/blob/v6.0.0/etc/notes/CHANGES_5.0.0.md),
[v6](https://github.com/mongodb/node-mongodb-native/blob/v6.0.0/etc/notes/CHANGES_6.0.0.md)
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.

---
_Source: https://npm.io/package/@apostrophecms/emulate-mongo-3-driver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
