Skip to content

Commit

Permalink
support adding multiple cats for testing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
sitek94 committed Nov 25, 2023
1 parent 996638b commit 2e19ff4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 8 additions & 1 deletion apps/nestjs/src/cats/cats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import { Cat } from './schemas/cat.schema'
export class CatsService {
constructor(@InjectModel(Cat.name) private readonly catModel: Model<Cat>) {}

async create(createCatDto: CreateCatDto): Promise<Cat> {
async create(
createCatDto: CreateCatDto | CreateCatDto[],
): Promise<Cat | Cat[]> {
if (Array.isArray(createCatDto)) {
const createdCats = await this.catModel.insertMany(createCatDto)
return createdCats
}

const createdCat = await this.catModel.create(createCatDto)
return createdCat
}
Expand Down
1 change: 0 additions & 1 deletion apps/nestjs/src/cats/schemas/cat.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type CatDocument = HydratedDocument<Cat>

@Schema()
export class Cat implements CatInterface {
@Prop()
_id: string

@Prop()
Expand Down

0 comments on commit 2e19ff4

Please sign in to comment.