# @zakodium/adonis-mongodb

> MongoDB provider for AdonisJs

Latest version **0.21.0** (published 2026-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @zakodium/adonis-mongodb
pnpm add @zakodium/adonis-mongodb
yarn add @zakodium/adonis-mongodb
bun add @zakodium/adonis-mongodb
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.21.0 |
| Published | 2026-01-07 |
| First published | 2019-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 214.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 65 |
| Author | Michaël Zasso |
| Maintainers | stropitek, targos, lpatiny, zakodium-bot |
| Keywords | adonisjs, adonis, mongo, mongodb, orm, provider |

## Links

- npm: https://www.npmjs.com/package/@zakodium/adonis-mongodb
- Repository: https://github.com/zakodium/adonis-mongodb
- Homepage: https://github.com/zakodium/adonis-mongodb#readme
- Issues: https://github.com/zakodium/adonis-mongodb/issues
- npm.io page: https://npm.io/package/@zakodium/adonis-mongodb

## Dependencies (5)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [mongodb](https://npm.io/package/mongodb.md) ^7.0.0
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [cli-table3](https://npm.io/package/cli-table3.md) ^0.6.5
- [@poppinss/utils](https://npm.io/package/@poppinss/utils.md) ^5.0.0

## 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

- 0.21.0 (latest) — 2026-01-07
- 0.20.2 — 2025-01-15
- 0.20.1 — 2025-01-15
- 0.20.0 — 2025-01-15
- 0.19.0 — 2024-06-17
- 0.18.1 — 2023-11-10
- 0.18.0 — 2023-11-10
- 0.17.0 — 2023-09-22
- 0.16.0 — 2023-09-19
- 0.15.0 — 2023-05-22
- 0.14.4 — 2023-05-08
- 0.14.3 — 2023-03-07
- 0.14.2 — 2023-03-07
- 0.14.1 — 2023-03-06
- 0.14.0 — 2023-02-13
- … 36 more at https://npm.io/package/@zakodium/adonis-mongodb/versions

## README

# Adonis MongoDB

MongoDB provider for AdonisJS 5.

<h3 align="center">

  <a href="https://www.zakodium.com">
    <img src="https://www.zakodium.com/brand/zakodium-logo-white.svg" width="50" alt="Zakodium logo" />
  </a>

  <p>
    Maintained by <a href="https://www.zakodium.com">Zakodium</a>
  </p>

[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

| :warning: This module is unstable and in active development. Use at your own risk. |
| ---------------------------------------------------------------------------------- |

</h3>

## Prerequisites

This provider requires AdonisJS v5 and won't work with AdonisJS v4.

We recommend using MongoDB >=5.0. Earlier versions are not tested.

## Installation

```console
npm i @zakodium/adonis-mongodb
node ace configure @zakodium/adonis-mongodb
```

## Documentation

### Using with the authentication provider

Adonis MongoDB can be used to authenticate users with the `@adonisjs/auth` addon.
To enable it, edit the following files:

#### `contracts/auth.ts`

Example of a configuration with the session guard:

```ts
import {
  MongodbModelAuthProviderContract,
  MongodbModelAuthProviderConfig,
} from '@ioc:Zakodium/Mongodb/Odm';

import User from 'App/Models/User';

declare module '@ioc:Adonis/Addons/Auth' {
  interface ProvidersList {
    user: {
      implementation: MongodbModelAuthProviderContract<typeof User>;
      config: MongodbModelAuthProviderConfig<typeof User>;
    };
  }

  interface GuardsList {
    web: {
      implementation: SessionGuardContract<'user', 'web'>;
      config: SessionGuardConfig<'user'>;
    };
  }
}
```

#### `config/auth.ts`

```ts
import { AuthConfig } from '@ioc:Adonis/Addons/Auth';

const authConfig: AuthConfig = {
  guard: 'web',
  guards: {
    web: {
      driver: 'session',
      provider: {
        driver: 'mongodb-model',
      },
    },
  },
};

export default authConfig;
```

## Development

To run tests locally:

```bash
docker compose up -d
node reset-dev.mjs
npm test
docker compose down
```

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/@zakodium/adonis-mongodb.svg
[npm-url]: https://www.npmjs.com/package/@zakodium/adonis-mongodb
[ci-image]: https://github.com/zakodium/adonis-mongodb/workflows/Node.js%20CI/badge.svg?branch=main
[ci-url]: https://github.com/zakodium/adonis-mongodb/actions?query=workflow%3A%22Node.js+CI%22
[codecov-image]: https://img.shields.io/codecov/c/github/zakodium/adonis-mongodb.svg
[codecov-url]: https://codecov.io/gh/zakodium/adonis-mongodb
[download-image]: https://img.shields.io/npm/dm/@zakodium/adonis-mongodb.svg
[download-url]: https://www.npmjs.com/package/@zakodium/adonis-mongodb

---
_Source: https://npm.io/package/@zakodium/adonis-mongodb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
