Skip to content

Viijay-Kr/mongodb-aggregation-dts

Repository files navigation

mongodb-aggregation-dts

This library provides type definitions for mongodb aggregation pipelines and operators those which are not provided by the native driver.

Currently it is only intended for the purpose of providing editor intellisense such as auto completion, hover hints.

Once native mongodb supports these definitions this project will be archived. Track the status here

Table of Contents

Features

This library is built on top of the native node js driver. The aggregate method from the native library is overloaded to provide the extra definitions for pipeline stages. Therefore diagnostics is not possible because of loose type in the native driver

Type definitions

Overload

Install

npm

npm install mongodb-dts --save-dev

pnpm

pnpm add mongodb-dts --save-dev

yarn

yarn add mongodb-dts --save-dev

bun

bun add mongodb-dts --save-dev

Usage

TS config

// tsconfig.json
{
  "include": ["./node_modules/mongodb-aggregation-dts/types"]
}

NOTE: If you have excluded node_modules in your tsconfig#exclude option then this approach will not work. In this case follow the .d.ts approach

*.d.ts

Create a mongodb.d.ts file at the root of your project and add a reference to mongodb-aggregatio-dts

// mongodb.d.ts
/// <reference types="mongodb-aggregation-dts" />