0.0.5 • Published 2 years ago

nestjs-module-mongodb v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

nestjs-module-mongodb

NestJS module for MongoDB

Installation

npm install nestjs-module-mongodb

Usage

// app.module.ts
import { Module } from "@nestjs/common";
import { MongoModule } from "nestjs-module-mongodb";

@Module({
  imports: [MongoModule.forRoot("mongodb://localhost:27017/test")],
})
export class AppModule {}
// example.module.ts
import { Module } from "@nestjs/common";
import { MongoModule } from "nestjs-module-mongodb";

@Module({
  imports: [MongoModule.registerCollection("example")],
})
export class ExampleModule {}
// example.service.ts
import { Injectable } from "@nestjs/common";
import { InjectCollection } from "nestjs-module-mongodb";
import type { Collection } from "mongodb";

@Injectable()
export class ExampleService {
  constructor(
    @InjectCollection("example") private readonly collection: Collection
  ) {}
}
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago