import { BaseRepo } from '../../../../shared/infra/db/BaseRepo' ; import { _db_connect_promise } from '../../../../shared/infra/db/connection' ; import { Canvas } from '../../domain/canvas' ; import { CanvasMap } from '../../mappers/canvasMap' ; import { ICanvasRepo } from '../canvasRepo' ; export class MongoCanvasRepo extends BaseRepo implements ICanvasRepo { constructor ( ) { super ( _db_connect_promise , 'canvas' ) ; } async setCanvasData ( id , meetingId , data ) { await this . collection . updateOne ( { _id : id , meetingId } , { $set : { data } } ) ; } async getCanvasByCanvasId ( id ) { const canvas = await this . collection . findOne ( { _id : id , } ) ; return canvas ? CanvasMap . toDomain ( canvas ) : undefined ; } async insert ( canvas ) { const raw = CanvasMap . toPersistence ( canvas ) ; await this . collection . insertOne ( raw ) ; } async save ( canvas ) { const raw = CanvasMap . toPersistence ( canvas ) ; await this . collection . updateOne ( { _id : raw . _id } , { $set : { ... raw } } ) ; } }