import { Entity , ObjectIdColumn , BeforeInsert , BaseEntity } from 'typeorm' ; const { EdvClient } = require ( 'edv-client' ) ; @ Entity ( ) export class Base extends BaseEntity { @ ObjectIdColumn ( ) id ! : string ; @ ObjectIdColumn ( { name : 'id' } ) _id ! : string ; @ BeforeInsert ( ) public async validate ( ) { if ( ! this . _id && ! this . id ) { this . _id = await EdvClient . generateId ( ) ; } else { this . _id = this . id ; } } }