Skip to content

Commit

Permalink
feat: remove id virtual getters
Browse files Browse the repository at this point in the history
  • Loading branch information
jrassa committed Nov 4, 2024
1 parent acbca3c commit 5669d44
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/app/core/audit/audit.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const AuditSchema = new Schema<
}
},
{
id: false,
timestamps: {
createdAt: 'created',
updatedAt: false
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/audit/audit.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
/*
Expand All @@ -61,7 +61,7 @@ describe('Audit Service:', () => {
);

assert.deepStrictEqual(result, {
id: _id.toString(),
_id: result._id,
message: 'some message',
audit: {
auditType: 'eventType',
Expand Down
1 change: 1 addition & 0 deletions src/app/core/feedback/feedback.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const FeedbackSchema = new Schema<
assignee: { type: String }
},
{
id: false,
timestamps: {
createdAt: 'created',
updatedAt: 'updated'
Expand Down
25 changes: 14 additions & 11 deletions src/app/core/teams/team-role.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@ export interface ITeamRole {
* role:
* type: string
*/
export const TeamRoleSchema = new Schema<ITeamRole>({
_id: {
type: Schema.Types.ObjectId,
ref: 'Team'
export const TeamRoleSchema = new Schema<ITeamRole>(
{
_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);

Expand Down
1 change: 1 addition & 0 deletions src/app/core/teams/team.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const TeamSchema = new Schema<
}
},
{
id: false,
timestamps: {
createdAt: 'created',
updatedAt: 'updated'
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/teams/teams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
};
Expand Down
1 change: 1 addition & 0 deletions src/app/core/user/eua/eua.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const UserAgreementSchema = new Schema<
}
},
{
id: false,
timestamps: {
createdAt: 'created',
updatedAt: 'updated'
Expand Down
1 change: 1 addition & 0 deletions src/app/core/user/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ const UserSchema = new Schema<
teams: [TeamRoleSchema]
},
{
id: false,
timestamps: {
createdAt: 'created',
updatedAt: 'updated'
Expand Down

0 comments on commit 5669d44

Please sign in to comment.