Initial commit: NestJS NextJS pnpm monorepo
This commit is contained in:
commit
610dcf202b
175 files changed
+25172
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { Injectable,NotFoundException } from '@nestjs/common';
|
||||
import { ManufacturerCreateDto, ManufacturerUpdateDto } from '../_dto/manufacturer.dto';
|
||||
import { InjectModel } from '@nestjs/mongoose';
|
||||
import { Model } from 'mongoose';
|
||||
import { Manufacturer } from '../_entities/manufacturer.entity';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class ManufacturerService {
|
||||
constructor(
|
||||
@InjectModel(Manufacturer.name)
|
||||
private manufacturerModel: Model<Manufacturer>,
|
||||
) { }
|
||||
|
||||
create(dto: ManufacturerCreateDto) {
|
||||
return this.manufacturerModel.create(dto);
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.manufacturerModel
|
||||
.find();
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
const article = await this.manufacturerModel.findById(id);
|
||||
if (!article) throw new NotFoundException('Artikel nicht gefunden');
|
||||
return article;
|
||||
}
|
||||
|
||||
update(id: string, dto: ManufacturerUpdateDto) {
|
||||
return this.manufacturerModel.findByIdAndUpdate(id, dto, { new: true });
|
||||
}
|
||||
|
||||
remove(id: string) {
|
||||
return this.manufacturerModel.findByIdAndDelete(id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user