0.0.5 • Published 1 year ago

nestjs-module-mongodb v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
1 year 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

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago