import { model as NotificationModel } from '../../notifications.model.js'; const toPlain = (doc)=>{ if(!doc || typeof doc !== 'object') return doc; const { _id, ...rest } = doc.toObject ? doc.toObject() : { ...doc }; return _id === undefined ? rest : { id: String(_id), ...rest }; }; // NotificationRepository (Mongo): dünne Hülle um die Statics des Upstream-Modells. export const createNotificationRepository = ()=>({ async list() { return (await NotificationModel.getAll()).map(toPlain); }, async create(data) { return toPlain(await NotificationModel.addNotification(data)); }, async deleteByDismissKey(dismissKey) { return toPlain(await NotificationModel.deleteNotification(dismissKey)); } });