Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade mongoose version to 7 #4106

Merged
merged 9 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class DeleteTenant {
);

try {
return await this.tenantRepository.delete({
await this.tenantRepository.delete({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To respect the current response interface of void

_environmentId: command.environmentId,
_organizationId: command.organizationId,
identifier: command.identifier,
Expand Down
4 changes: 2 additions & 2 deletions libs/dal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"googleapis": "^60.0.1",
"intercom-client": "^2.11.0",
"jsonfile": "^6.0.1",
"mongoose": "6.11.3",
"mongoose-delete": "^0.5.4",
"mongoose": "^7.5.0",
"mongoose-delete": "^1.0.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching a supporting version for the delete package

"ng-intercom": "^8.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
Expand Down
9 changes: 7 additions & 2 deletions libs/dal/src/repositories/base-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ export class BaseRepository<T_DBModel, T_MappedEntity, T_Enforcement = object> {
return this.mapEntity(data.toObject());
}

async delete(query: FilterQuery<T_DBModel> & T_Enforcement): Promise<void> {
return await this.MongooseModel.remove(query);
async delete(query: FilterQuery<T_DBModel> & T_Enforcement): Promise<{
/** Indicates whether this writes result was acknowledged. If not, then all other members of this result will be undefined. */
acknowledged: boolean;
/** The number of documents that were deleted */
deletedCount: number;
Comment on lines +62 to +65
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to do that, since the type is not exported from mongoose

}> {
return await this.MongooseModel.deleteMany(query);
}

async find(
Expand Down
2 changes: 1 addition & 1 deletion libs/dal/src/repositories/feed/feed.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FeedRepository extends BaseRepository<FeedDBModel, FeedEntity, Enfo
);
if (relatedMessages.length) throw new DalException(`Can not delete feed that has existing message`);

await this.feed.delete({ _id: feed._id, _environmentId: feed._environmentId });
return await this.feed.delete({ _id: feed._id, _environmentId: feed._environmentId });
}

async findDeleted(query: FilterQuery<FeedEntity>): Promise<FeedEntity> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class IntegrationRepository extends BaseRepository<IntegrationDBModel, In
const integration = await this.findOne({ _id: query._id, _organizationId: query._organizationId });
if (!integration) throw new DalException(`Could not find integration with id ${query._id}`);

await this.integration.delete({ _id: integration._id, _organizationId: integration._organizationId });
return await this.integration.delete({ _id: integration._id, _organizationId: integration._organizationId });
}

async deleteMany(query: IntegrationQuery): Promise<IDeleteResult> {
Expand Down
12 changes: 10 additions & 2 deletions libs/dal/src/repositories/member/member.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ export class MemberRepository extends BaseRepository<MemberDBModel, MemberEntity
super(Member, MemberEntity);
}

async removeMemberById(organizationId: string, memberId: string) {
return this.MongooseModel.remove({
async removeMemberById(
organizationId: string,
memberId: string
): Promise<{
/** Indicates whether this write result was acknowledged. If not, then all other members of this result will be undefined. */
acknowledged: boolean;
/** The number of documents that were deleted */
deletedCount: number;
}> {
return this.MongooseModel.deleteOne({
_id: memberId,
_organizationId: organizationId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export class MessageTemplateRepository extends BaseRepository<
throw new DalException(`Could not find a message template with id ${query._id}`);
}

await this.messageTemplate.delete({ _id: messageTemplate._id, _environmentId: messageTemplate._environmentId });
return await this.messageTemplate.delete({
_id: messageTemplate._id,
_environmentId: messageTemplate._environmentId,
});
}

async findDeleted(query: MessageTemplateQuery): Promise<MessageTemplateEntity> {
Expand Down
2 changes: 1 addition & 1 deletion libs/dal/src/repositories/message/message.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class MessageRepository extends BaseRepository<MessageDBModel, MessageEnt
throw new DalException(`Could not find a message with id ${query._id}`);
}

await this.message.delete({ _id: message._id, _environmentId: message._environmentId });
return await this.message.delete({ _id: message._id, _environmentId: message._environmentId });
}

async deleteMany(query: MessageQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class NotificationTemplateRepository extends BaseRepository<
async delete(query: NotificationTemplateQuery) {
const item = await this.findOne({ _id: query._id, _environmentId: query._environmentId });
if (!item) throw new DalException(`Could not find workflow with id ${query._id}`);
await this.notificationTemplate.delete({ _id: item._id, _environmentId: item._environmentId });

return await this.notificationTemplate.delete({ _id: item._id, _environmentId: item._environmentId });
}

async findDeleted(query: NotificationTemplateQuery): Promise<NotificationTemplateEntity> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class SubscriberRepository extends BaseRepository<SubscriberDBModel, Subs
subscriberId: foundSubscriber.subscriberId,
};

await this.subscriber.delete(requestQuery);
return await this.subscriber.delete(requestQuery);
}

async findDeleted(query: SubscriberQuery) {
Expand Down
2 changes: 1 addition & 1 deletion libs/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"event-stream": "^4.0.1",
"fs-extra": "^9.0.0",
"jsonfile": "^6.0.1",
"mongoose": "6.11.3",
"mongoose": "^7.5.0",
"ng-intercom": "^8.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
Expand Down
87 changes: 59 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.