#Is there any way to get the metadata of the properties of a class who use a decorator?

6 messages · Page 1 of 1 (latest)

severe ravine
#

Eg: I have user.entity.ts


@Column()
name: string

@Column()
email: string

@Column()
status: boolean

}```

I can't figure out a way to get the metadata of the properties from the class.

Something like `const data = Reflector.getAll(new User(), 'Column')`

Any ideas?
white copper
#

Was wondering about this too, it would be great for testing validation rules

delicate glade
#

Look into how the Column() decorator is implemented. It probably sets some metadata key on the class. You can read the keys that with Reflect.getMetadataKeys(User) (https://www.npmjs.com/package/reflect-metadata)

#

(nest's Reflector is just an abstraction over reflect-metadata , so you can use it too)

severe ravine
#

I looked at the typeorm implementation but I don;t really understand it, it's a bit advanced for me