Skip to main content

EntityOptions

The options object accepted by @Entity(). See Defining Models for the full guide, including the string shorthand form.

type EntityOptions = Partial<
Pick<EntityMetadata, 'name' | 'schema' | 'comment' | 'tableName'>
>;
FieldTypeDescription
tableNamestringDatabase table name. Defaults to the class name (ctor.name, used verbatim, no case conversion) when omitted. Equivalent to passing a bare string to @Entity('table_name').
schemastringDatabase schema the table lives in.
commentstringTable comment, recorded on EntityMetadata.comment.
namestringPresent on the type (inherited from Pick<EntityMetadata, ...>), but not read by the @Entity decorator — EntityMetadata.name always mirrors the class's own ctor.name regardless of what you pass here.
@Entity({ tableName: 'customers', schema: 'public', comment: 'Customer accounts' })
class Customer {}

// equivalent, tableName-only shorthand
@Entity('customers')
class Customer {}