Skip to content

Commit

Permalink
fix(mongo): users secondary key
Browse files Browse the repository at this point in the history
  • Loading branch information
Ealenn committed Jun 11, 2022
1 parent 3a548d7 commit f42e0f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
10 changes: 2 additions & 8 deletions src/controllers/floors/models/mapper.profiles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Mapper,
MappingProfile,
createMap,
forMember,
mapFrom,
} from '@automapper/core';
import { Mapper, MappingProfile, createMap, forMember, mapFrom } from '@automapper/core';
import { AutomapperProfile, InjectMapper } from '@automapper/nestjs';
import { Injectable } from '@nestjs/common';
import { Floor } from '../../../entities/floors/models/floor.entity';
Expand Down Expand Up @@ -37,7 +31,7 @@ export class FloorMapperProfiles extends AutomapperProfile {
),
forMember(
(d) => d.createdBy,
mapFrom((s) => s.createdBy),
mapFrom((s) => s.createdBy.toString()),
),
forMember(
(d) => d.createdAt,
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/plants/models/mapper.profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class PlantMapperProfiles extends AutomapperProfile {
),
forMember(
(d) => d.createdBy,
mapFrom((s) => s.createdBy),
mapFrom((s) => s.createdBy.toString()),
),
forMember(
(d) => d.createdAt,
Expand Down
5 changes: 3 additions & 2 deletions src/entities/base.entity.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Prop } from '@nestjs/mongoose';
import mongoose from 'mongoose';
import { User } from 'src/users/models/user.entity';

export class BaseEntity {
_id: mongoose.Types.ObjectId;

@Prop({ required: true })
createdBy: string;
@Prop({ required: true, type: [{ type: mongoose.Schema.Types.ObjectId, ref: User.name }] })
createdBy: mongoose.Types.ObjectId;

@Prop({ required: true })
createdAt: Date;
Expand Down
4 changes: 1 addition & 3 deletions src/entities/plants/models/requirement.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export class PlantRequirement {
@Prop({ required: true })
sun: PlantRequirementSun;

@Prop({
type: [{ type: mongoose.Schema.Types.ObjectId, ref: Floor.name }],
})
@Prop({ type: [{ type: mongoose.Schema.Types.ObjectId, ref: Floor.name }] })
floors: mongoose.Types.ObjectId[];
}

0 comments on commit f42e0f8

Please sign in to comment.