From 5669d44b01a25bd5545114849a883637c553d7f5 Mon Sep 17 00:00:00 2001 From: John Rassa Date: Mon, 4 Nov 2024 11:51:10 -0500 Subject: [PATCH] feat: remove id virtual getters --- src/app/core/audit/audit.model.ts | 1 + src/app/core/audit/audit.service.spec.ts | 4 ++-- src/app/core/feedback/feedback.model.ts | 1 + src/app/core/teams/team-role.model.ts | 25 +++++++++++++----------- src/app/core/teams/team.model.ts | 1 + src/app/core/teams/teams.service.ts | 2 +- src/app/core/user/eua/eua.model.ts | 1 + src/app/core/user/user.model.ts | 1 + 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/app/core/audit/audit.model.ts b/src/app/core/audit/audit.model.ts index cf1b23da..22d5d68a 100644 --- a/src/app/core/audit/audit.model.ts +++ b/src/app/core/audit/audit.model.ts @@ -61,6 +61,7 @@ const AuditSchema = new Schema< } }, { + id: false, timestamps: { createdAt: 'created', updatedAt: false diff --git a/src/app/core/audit/audit.service.spec.ts b/src/app/core/audit/audit.service.spec.ts index a1cb7dc7..81373ade 100644 --- a/src/app/core/audit/audit.service.spec.ts +++ b/src/app/core/audit/audit.service.spec.ts @@ -47,7 +47,7 @@ describe('Audit Service:', () => { assert(Array.isArray(results), 'results should be an Array'); assert.equal(results.length, 1); - const { created, _id, ...result } = results[0].toObject({ + const { created, ...result } = results[0].toObject({ versionKey: false }); /* @@ -61,7 +61,7 @@ describe('Audit Service:', () => { ); assert.deepStrictEqual(result, { - id: _id.toString(), + _id: result._id, message: 'some message', audit: { auditType: 'eventType', diff --git a/src/app/core/feedback/feedback.model.ts b/src/app/core/feedback/feedback.model.ts index ef376e17..09bd92f3 100644 --- a/src/app/core/feedback/feedback.model.ts +++ b/src/app/core/feedback/feedback.model.ts @@ -69,6 +69,7 @@ const FeedbackSchema = new Schema< assignee: { type: String } }, { + id: false, timestamps: { createdAt: 'created', updatedAt: 'updated' diff --git a/src/app/core/teams/team-role.model.ts b/src/app/core/teams/team-role.model.ts index c0d47130..ee80e6a2 100644 --- a/src/app/core/teams/team-role.model.ts +++ b/src/app/core/teams/team-role.model.ts @@ -47,18 +47,21 @@ export interface ITeamRole { * role: * type: string */ -export const TeamRoleSchema = new Schema({ - _id: { - type: Schema.Types.ObjectId, - ref: 'Team' +export const TeamRoleSchema = new Schema( + { + _id: { + type: Schema.Types.ObjectId, + ref: 'Team' + }, + role: { + type: String, + trim: true, + default: TeamRoles.Member, + enum: TeamRoles + } }, - role: { - type: String, - trim: true, - default: TeamRoles.Member, - enum: TeamRoles - } -}); + { id: false } +); TeamRoleSchema.plugin(getterPlugin); diff --git a/src/app/core/teams/team.model.ts b/src/app/core/teams/team.model.ts index 8ca260b1..2a9bc215 100644 --- a/src/app/core/teams/team.model.ts +++ b/src/app/core/teams/team.model.ts @@ -97,6 +97,7 @@ const TeamSchema = new Schema< } }, { + id: false, timestamps: { createdAt: 'created', updatedAt: 'updated' diff --git a/src/app/core/teams/teams.service.ts b/src/app/core/teams/teams.service.ts index 80d5b129..0ab179c8 100644 --- a/src/app/core/teams/teams.service.ts +++ b/src/app/core/teams/teams.service.ts @@ -187,7 +187,7 @@ class TeamsService { // append isMember field to elements if user is part of the team return { ...res.toJSON(), - isMember: teamIdStrings.includes(res.id) + isMember: teamIdStrings.includes(res._id.toString()) } as unknown as TeamDocument; }) }; diff --git a/src/app/core/user/eua/eua.model.ts b/src/app/core/user/eua/eua.model.ts index 70ad3546..7c88ac21 100644 --- a/src/app/core/user/eua/eua.model.ts +++ b/src/app/core/user/eua/eua.model.ts @@ -64,6 +64,7 @@ const UserAgreementSchema = new Schema< } }, { + id: false, timestamps: { createdAt: 'created', updatedAt: 'updated' diff --git a/src/app/core/user/user.model.ts b/src/app/core/user/user.model.ts index fbc0d47a..db79c346 100644 --- a/src/app/core/user/user.model.ts +++ b/src/app/core/user/user.model.ts @@ -247,6 +247,7 @@ const UserSchema = new Schema< teams: [TeamRoleSchema] }, { + id: false, timestamps: { createdAt: 'created', updatedAt: 'updated'