nestjs-starter
Version:
Get started for beginners with Nestjs
21 lines (17 loc) • 520 B
text/typescript
import { Model } from 'mongoose';
import { Injectable, Inject } from '@nestjs/common';
import { Cat, CatDocument } from '../../schemas/cat.schema';
()
export class CatsService {
constructor(
private catModel: Model<CatDocument>
) {}
(Cat.name)
async create(createCatDto: any): Promise<Cat> {
const createdCat = new this.catModel(createCatDto);
return createdCat.save();
}
async findAll(): Promise<Cat[]> {
return this.catModel.find().exec();
}
}