huridocs/uwazi

View on GitHub
app/api/entities.v2/database/EntityMapper.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { MongoIdHandler } from 'api/common.v2/database/MongoIdGenerator';
import { Entity } from '../model/Entity';
import { EntityDBO } from './schemas/EntityTypes';

export const EntityMappers = {
  toModel(dbo: EntityDBO) {
    return new Entity(
      MongoIdHandler.mapToApp(dbo._id),
      dbo.sharedId,
      dbo.language,
      dbo.title,
      MongoIdHandler.mapToApp(dbo.template),
      dbo.metadata,
      dbo.obsoleteMetadata
    );
  },
};