extract shared mongo mapper utils

This commit is contained in:
Alex Holliday committed 2026-07-15 10:20:16 -07:00
1 parent bd13e9d9c8
commit 825a81d326
16 files changed
+89 -268

No files matched your search

@@ -3,6 +3,7 @@ import { NotificationModel, type NotificationDocument } from "@/domain/notificat
import { INotificationsRepository } from "@/domain/notifications/notification.repository.interface.js";
import type { Notification } from "@/domain/notifications/notification.type.js";
import { AppError } from "@/utils/AppError.js";
import { toStringId, toDateString } from "@/utils/mongoMappers.js";
class MongoNotificationsRepository implements INotificationsRepository {
private mapDocuments = (documents: NotificationDocument[]): Notification[] => {
@@ -13,14 +14,6 @@ class MongoNotificationsRepository implements INotificationsRepository {
};
private toEntity = (doc: NotificationDocument): Notification => {
const toStringId = (value: mongoose.Types.ObjectId | string): string => {
return value instanceof mongoose.Types.ObjectId ? value.toString() : value;
};
const toDateString = (value: Date | string): string => {
return value instanceof Date ? value.toISOString() : value;
};
return {
id: toStringId(doc._id),
userId: toStringId(doc.userId),