-
Notifications
You must be signed in to change notification settings - Fork 0
modified the backend documentation file #21
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
base: main
Are you sure you want to change the base?
Conversation
fa65459
to
fd682b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This have merge conflicts
I have resolved the conflicts. @willypelz |
@@ -39,6 +39,7 @@ | |||
"@nestjs/mongoose": "^10.0.1", | |||
"@nestjs/passport": "^10.0.2", | |||
"@nestjs/platform-express": "^10.0.0", | |||
"@nestjs/schedule": "^4.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DennisTemoye why do we have the nestjs/schedule brought into the code?
This PR is having some conflicts @DennisTemoye can you fix this and would be good to be merged.
|
async createNotification( | ||
message: string, | ||
link: string, | ||
userIds: string[], | ||
roles: string[], | ||
): Promise<Notification> { | ||
const notification = new this.notificationModel({ | ||
message, | ||
link, | ||
userIds, | ||
roles, | ||
}); | ||
return await notification.save(); | ||
} | ||
|
||
async getNotifications( | ||
userIds?: string[], | ||
roles?: string[], | ||
): Promise<Notification[]> { | ||
const query: any = { | ||
$or: [], | ||
}; | ||
|
||
// If userIds are provided, add them to the query | ||
if (userIds && userIds.length > 0) { | ||
query.$or.push({ userIds: { $in: userIds } }); | ||
} | ||
|
||
// If roles are provided, add them to the query | ||
if (roles && roles.length > 0) { | ||
query.$or.push({ roles: { $in: roles } }); | ||
} | ||
|
||
// If no filters are provided, return an empty array or all notifications as needed | ||
if (query.$or.length === 0) { | ||
return []; // or return await this.notificationModel.find().lean().exec(); to fetch all | ||
} | ||
|
||
return await this.notificationModel.find(query).lean().exec(); | ||
} | ||
|
||
async markAsRead(notificationId: string): Promise<Notification> { | ||
return await this.notificationModel | ||
.findByIdAndUpdate(notificationId, { isRead: true }, { new: true }) | ||
.lean() | ||
.exec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR title says modify the backend documentation, it might make sense to move this change to a separate PR or add some description on the PR on these changes and add unit test. Nicely done.
@DennisTemoye any update on this PR |
@DennisTemoye, this issue remains unresolved.(Conflicts with the main branch) |
I modified the backend documentation by removing the nestjs template from the documentation.