Files
homebrewery-oidc/server/storage/mongo/notifications.js
T
dev-bot BotandClaude Sonnet 5.5 a55c403527 feat(storage): Repository-Schicht für Brews/Notifications, PostgreSQL-18-Backend (Kysely) und Contract-Suite
HB_DB_DRIVER=mongo|postgres, versionierte Migrationen beim Start, Mongo-Backend ruft unverändert die Upstream-Modelle.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 10:16:55 +00:00

21 lines
716 B
JavaScript

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));
}
});