import "reflect-metadata" ; import { EntitySchemaField } from "./schema/entity-schema-field" ; /**
 * Decorator (Annotation `@DatabaseField()`) to mark a property of an Entity that should be persisted in the database.
 *
 * also see  {@link /additional-documentation/how-to-guides/create-a-new-entity-type.html} param propertySchema export function DatabaseField ( propertySchema = { } ) { return ( target , propertyName ) => { if ( propertySchema . dataType === undefined ) { propertySchema . dataType = Reflect . getMetadata ( "design:type" , target , propertyName ) . name . toLowerCase ( ) ; } addPropertySchema ( target , propertyName , propertySchema ) ; } ; } export function addPropertySchema ( target , propertyName , propertySchema ) { target [ propertyName ] = undefined ; if ( Object . getOwnPropertyDescriptor ( target . constructor , "schema" ) == null ) { target . constructor . schema = new Map < string , EntitySchemaField > ( ) ; } target . constructor . schema . set ( propertyName , propertySchema ) ; return target ; }