Skip to content

Commit

Permalink
Merge branch 'data-generator'
Browse files Browse the repository at this point in the history
  • Loading branch information
publdaze committed Aug 9, 2023
2 parents 80f016c + 40900c9 commit a553ca5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/buildings/buildings.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ export class BuildingsRepository {
const buildingDoc = await this.buildingModel.findOneAndUpdate(
{ buildingNumber: buildingNumber, 'floors.floorNumber': floorNumber },
{
$push: {
'floors.$.trashCans': {
$set: {
'floors.$.trashCan': {
status: {
regular: null,
bottle: null,
plastic: null,
paper: null,
regular: 0,
bottle: 0,
plastic: 0,
paper: 0,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/buildings/floors/cans/cans.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CansService } from './cans.service';
export class CansController {
constructor(private readonly cansService: CansService) {}

@Post('/buildings/:buildingNumber/floors/:floorNumber/cans')
@Post('/buildings/:buildingNumber/floors/:floorNumber/can')
createTrashCan(
@Param('buildingNumber') buildingNumber: number,
@Param('floorNumber') floorNumber: number,
Expand Down
10 changes: 3 additions & 7 deletions src/buildings/floors/cans/cans.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BuildingsRepository } from 'src/buildings/buildings.repository';
@Injectable()
export class CansService {
constructor(private readonly buildingRepository: BuildingsRepository) {}

createCan({
buildingNumber,
floorNumber,
Expand All @@ -29,14 +30,9 @@ export class CansService {
return res.map(({ buildingNumber, buildingName, floors }) => ({
buildingNumber,
buildingName,
floors: floors.map(({ floorNumber, trashCans }) => ({
floors: floors.map(({ floorNumber, trashCan }) => ({
floorNumber,
trashCans: trashCans.map(({ _id, status }) => {
return {
canId: _id,
status,
};
}),
trashCan,
})),
}));
})
Expand Down
4 changes: 2 additions & 2 deletions src/buildings/floors/entities/floor.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export class Floor {
@Prop()
floorNumber: number;

@Prop([Can])
trashCans: Can[];
@Prop(Can)
trashCan: Can;

@Prop({ default: new Date(), type: mongoose.Schema.Types.Date })
createdAt: Date;
Expand Down

0 comments on commit a553ca5

Please sign in to comment.