import { BaseRepo } from '../../../../shared/infra/db/BaseRepo' ; import { _db_connect_promise } from '../../../../shared/infra/db/connection' ; import { Meeting } from '../../domain/meeting' ; import { MeetingMap } from '../../mappers/meetingMap' ; import { IMeetingRepo } from '../meetingRepo' ; export class MongoMeetingRepo extends BaseRepo implements IMeetingRepo { constructor ( ) { super ( _db_connect_promise , 'meetings' ) ; } async getMeetingByMeetingId ( id ) { const meeting = await this . collection . findOne ( { _id : id , } ) ; return meeting ? MeetingMap . toDomain ( meeting ) : undefined ; } async deleteMeetingByMeetingId ( id ) { await this . collection . findOneAndDelete ( { _id : id , } ) ; } async setMeetingActiveCanvas ( id , canvasId ) { await this . collection . updateOne ( { _id : id , canvasIds : canvasId } , { $set : { activeCanvasId : canvasId } } ) ; } async insert ( meeting ) { const raw = MeetingMap . toPersistence ( meeting ) ; await this . collection . insertOne ( raw ) ; } async save ( meeting ) { const raw = MeetingMap . toPersistence ( meeting ) ; await this . collection . updateOne ( { _id : raw . _id } , { $set : { ... raw } } ) ; } }