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
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
npm install mongodb-dts --save-dev
pnpm add mongodb-dts --save-dev
yarn add mongodb-dts --save-dev
bun add mongodb-dts --save-dev
// tsconfig.json
{
"include": ["./node_modules/mongodb-aggregation-dts/types"]
}
NOTE: If you have excluded
node_modules
in yourtsconfig#exclude
option then this approach will not work. In this case follow the .d.ts approach
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" />