import { Column , Entity } from 'typeorm' ; import { Base } from '../Base/NoSqlBase' ; import { ChunkBindingModel } from './ChunkBindingModel' ; import { Jwe } from '../../types/Jwe' ; @ Entity ( ) export class Chunk extends Base { @ Column ( ) edvId ? : string ; @ Column ( ) docId ? : string ; @ Column ( ) index ? : number ; @ Column ( ) sequence ? : string ; @ Column ( ) offset ? : number ; @ Column ( ) jwe ? : Jwe ; static fromBindingModel ( bindingModel ) { const entity = new Chunk ( ) ; Object . keys ( bindingModel ) . forEach ( ( k ) => { entity [ k ] = ( bindingModel as any ) [ k ] ; } ) ; return entity ; } public toFs ( baseUrl ) { const chunk = { id : `${ baseUrl }/${ this . index }` , sequence : this . sequence , index : this . index , offset : this . offset , jwe : this . jwe } ; return JSON . stringify ( chunk , null , 2 ) ; } }