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>
21 lines
716 B
JavaScript
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));
|
|
}
|
|
});
|