import { Column , Index } from 'typeorm' ; import { ColumnCommonOptions } from 'typeorm/decorator/options/ColumnCommonOptions' ; import { ColumnWithWidthOptions } from 'typeorm/decorator/options/ColumnWithWidthOptions' ; import { Timestamp , AnyConstructor } from '@mds-core/mds-types' ; import { BigintTransformer } from '../transformers' ; import { Mixin } from '../@types' ; export const RecordedColumn = < T extends AnyConstructor > ( EntityClass , options = { } ) => { abstract class RecordedColumnMixin extends EntityClass { @ Column ( 'bigint' , { transformer : BigintTransformer , default : ( ) => '(extract(epoch from now()) * 1000)::bigint' , ... options } ) @ Index ( ) recorded : Timestamp ; } return RecordedColumnMixin ; } ; export type RecordedColumn = Mixin < typeof RecordedColumn > ;