Stuck in the middle and No errors reported
// mongodb connection
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
@Module({
imports: [
MongooseModule.forRootAsync({
useFactory: () => ({
uri: `mongodb://${process.env.MONGODB_SERVER}:${process.env.MONGODB_PORT}`,
dbName: process.env.MONGODB_DBNAME,
}),
}),
],
exports: [],
})
export class MongodbModule {}
// schema
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
export type ListDocument = List & Document;
@Schema()
export class List extends Document {
@Prop({ default: '' })
notes: string;
}
export const ListSchema = SchemaFactory.createForClass(List);
// list module
import { Module } from '@nestjs/common';
import { TestService } from './test.service';
import { TestController } from './test.controller';
import { MongooseModule } from '@nestjs/mongoose';
import { List, ListSchema } from 'src/database/mongodb/schema/list.schema';
@Module({
imports: [MongooseModule.forFeature([{ name: List.name, schema: ListSchema }])],
controllers: [TestController],
providers: [TestService],
})
export class TestModule {}
// service
import { Injectable } from '@nestjs/common';
@Injectable()
export class TestService {}
// controller
import { Controller } from '@nestjs/common';
import { TestService } from './test.service';
@Controller('test')
export class TestController {
constructor(private readonly testService: TestService) {}
}