import { MetadataStorage } from '../metadata' ; import { ReferenceType } from '../enums' ; import type { EntityProperty , AnyEntity } from '../typings' ; import { Utils } from '../utils/Utils' ; import type { PropertyOptions } from './Property' ; export function Formula < T > ( formula , options = { } ) { return function ( target , propertyName ) { const meta = MetadataStorage . getMetadataFromDecorator ( target . constructor ) ; meta . properties [ propertyName ] = Object . assign ( { name : propertyName , reference : ReferenceType . SCALAR , persist : false , formula } , options ) as EntityProperty ; return Utils . propertyDecoratorReturnValue ( ) ; } ; } export interface FormulaOptions < T > extends PropertyOptions < T > { }