Skip to content

Commit b499aac

Browse files
docs(@nestjs) update mongoose example
1 parent cff72ef commit b499aac

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

examples/06-mongoose/src/modules/cats/cats.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Model } from 'mongoose';
22
import { Component, Inject } from '@nestjs/common';
33
import { Cat } from './interfaces/cat.interface';
4-
import { CatsModule } from './cats.module';
54
import { CreateCatDto } from './dto/create-cat.dto';
65

76
@Component()
@@ -10,8 +9,8 @@ export class CatsService {
109
@Inject('CatModelToken') private readonly catModel: Model<Cat>) {}
1110

1211
async create(createCatDto: CreateCatDto): Promise<Cat> {
13-
const cat = new this.catModel(createCatDto);
14-
return await cat.save();
12+
const createdCat = new this.catModel(createCatDto);
13+
return await createdCat.save();
1514
}
1615

1716
async findAll(): Promise<Cat[]> {

examples/06-mongoose/src/modules/database/database.providers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as mongoose from 'mongoose';
33
export const databaseProviders = [
44
{
55
provide: 'DbConnectionToken',
6-
useFactory: async () => {
6+
useFactory: async (): Promise<mongoose.Connection> => {
77
(mongoose as any).Promise = global.Promise;
88
return await mongoose.connect('mongodb://localhost/nest', {
99
useMongoClient: true,

0 commit comments

Comments
 (0)