API 参考
    正在准备搜索索引...

    Contains all entity metadata.

    索引

    构造函数

    属性

    方法

    构造函数

    • 参数

      • options: {
            args: TableMetadataArgs;
            connection: DataSource;
            inheritancePattern?: "STI";
            inheritanceTree?: Function[];
            parentClosureEntityMetadata?: EntityMetadata;
            tableTree?: TreeMetadataArgs;
        }

      返回 EntityMetadata

    属性

    "@instanceof": symbol
    afterInsertListeners: EntityListenerMetadata[]

    Listener metadatas with "AFTER INSERT" type.

    afterLoadListeners: EntityListenerMetadata[]

    Listener metadatas with "AFTER LOAD" type.

    afterRecoverListeners: EntityListenerMetadata[]

    Listener metadatas with "AFTER RECOVER" type.

    afterRemoveListeners: EntityListenerMetadata[]

    Listener metadatas with "AFTER REMOVE" type.

    afterSoftRemoveListeners: EntityListenerMetadata[]

    Listener metadatas with "AFTER SOFT REMOVE" type.

    afterUpdateListeners: EntityListenerMetadata[]

    Listener metadatas with "AFTER UPDATE" type.

    allEmbeddeds: EmbeddedMetadata[]

    All embeddeds - embeddeds from this entity metadata and from all child embeddeds, etc.

    ancestorColumns: ColumnMetadata[]

    Ancestor columns used only in closure junction tables.

    beforeInsertListeners: EntityListenerMetadata[]

    Listener metadatas with "BEFORE INSERT" type.

    beforeRecoverListeners: EntityListenerMetadata[]

    Listener metadatas with "BEFORE RECOVER" type.

    beforeRemoveListeners: EntityListenerMetadata[]

    Listener metadatas with "BEFORE REMOVE" type.

    beforeSoftRemoveListeners: EntityListenerMetadata[]

    Listener metadatas with "BEFORE SOFT REMOVE" type.

    beforeUpdateListeners: EntityListenerMetadata[]

    Listener metadatas with "BEFORE UPDATE" type.

    checks: CheckMetadata[]

    Entity's check metadatas.

    childEntityMetadatas: EntityMetadata[]

    Children entity metadatas. Used in inheritance patterns.

    closureJunctionTable: EntityMetadata

    If entity's table is a closure-typed table, then this entity will have a closure junction table metadata.

    columns: ColumnMetadata[]

    Columns of the entity, including columns that are coming from the embeddeds of this entity.

    comment?: string

    Table comment. Not supported by all database types.

    connection: DataSource

    Connection where this entity metadata is created.

    createDateColumn?: ColumnMetadata

    Gets entity column which contains a create date value.

    database?: string

    Database name.

    deleteDateColumn?: ColumnMetadata

    Gets entity column which contains a delete date value.

    dependsOn?: Set<string | Function>

    View's dependencies. Used in views

    descendantColumns: ColumnMetadata[]

    Descendant columns used only in closure junction tables.

    discriminatorColumn?: ColumnMetadata

    Gets the discriminator column used to store entity identificator in single-table inheritance tables.

    discriminatorValue?: string

    If this entity metadata is a child table of some table, it should have a discriminator value. Used to store a value in a discriminator column.

    eagerRelations: RelationMetadata[]

    List of eager relations this metadata has.

    embeddeds: EmbeddedMetadata[]

    Entity's embedded metadatas.

    engine?: string

    Table's database engine type (like "InnoDB", "MyISAM", etc).

    exclusions: ExclusionMetadata[]

    Entity's exclusion metadatas.

    expression?: string | ((connection: DataSource) => SelectQueryBuilder<any>)

    View's expression. Used in views

    foreignKeys: ForeignKeyMetadata[]

    Entity's foreign key metadatas.

    generatedColumns: ColumnMetadata[]

    Gets the column with generated flag.

    givenTableName?: string

    Original user-given table name (taken from schema or @Entity(tableName) decorator). If user haven't specified a table name this property will be undefined.

    hasMultiplePrimaryKeys: boolean

    Checks if entity's table has multiple primary columns.

    hasNonNullableRelations: boolean

    Checks if there any non-nullable column exist in this entity.

    hasUUIDGeneratedColumns: boolean

    Indicates if this entity metadata has uuid generated columns.

    indices: IndexMetadata[]

    Entity's index metadatas.

    inheritancePattern?: "STI"

    If this entity metadata's table using one of the inheritance patterns, then this will contain what pattern it uses.

    inheritanceTree: Function[]

    All "inheritance tree" from a target entity. For example for target Post < ContentModel < Unit it will be an array of [Post, ContentModel, Unit]. It also contains child entities for single table inheritance.

    inverseColumns: ColumnMetadata[]

    In the case if this entity metadata is junction table's entity metadata, this will contain all referenced columns of inverse entity.

    isAlwaysUsingConstructor: boolean

    Indicates if the entity should be instantiated using the constructor or via allocating a new object via Object.create().

    isClosureJunction: boolean

    Checks if this table is a junction table of the closure table. This type is for tables that contain junction metadata of the closure tables.

    isJunction: boolean

    Indicates if this entity metadata of a junction table, or not. Junction table is a table created by many-to-many relationship.

    Its also possible to understand if entity is junction via tableType.

    lazyRelations: RelationMetadata[]

    List of eager relations this metadata has.

    listeners: EntityListenerMetadata[]

    Entity listener metadatas.

    manyToManyRelations: RelationMetadata[]

    Gets only many-to-many relations of the entity.

    manyToOneRelations: RelationMetadata[]

    Gets only many-to-one relations of the entity.

    materializedPathColumn?: ColumnMetadata

    Materialized path column. Used only in tree entities with materialized path pattern applied.

    name: string

    Entity's name. Equal to entity target class's name if target is set to table. If target class is not then then it equals to table name.

    nestedSetLeftColumn?: ColumnMetadata

    Nested set's left value column. Used only in tree entities with nested set pattern applied.

    nestedSetRightColumn?: ColumnMetadata

    Nested set's right value column. Used only in tree entities with nested set pattern applied.

    nonVirtualColumns: ColumnMetadata[]

    All columns except for virtual columns.

    objectIdColumn?: ColumnMetadata

    Gets the object id column used with mongodb database.

    oneToManyRelations: RelationMetadata[]

    Gets only one-to-many relations of the entity.

    oneToOneRelations: RelationMetadata[]

    Gets only one-to-one relations of the entity.

    Specifies a default order by used for queries from this table when no explicit order by is specified.

    ownColumns: ColumnMetadata[]

    Entity's column metadatas defined by user.

    ownerColumns: ColumnMetadata[]

    In the case if this entity metadata is junction table's entity metadata, this will contain all referenced columns of owner entity.

    ownerManyToManyRelations: RelationMetadata[]

    Gets only owner many-to-many relations of the entity.

    ownerOneToOneRelations: RelationMetadata[]

    Gets only owner one-to-one relations of the entity.

    ownIndices: IndexMetadata[]

    Entity's own indices.

    ownListeners: EntityListenerMetadata[]

    Entity's own listener metadatas.

    ownRelations: RelationMetadata[]

    Entity's relation metadatas.

    ownUniques: UniqueMetadata[]

    Entity's own uniques.

    parentClosureEntityMetadata: EntityMetadata

    If this is entity metadata for a junction closure table then its owner closure table metadata will be set here.

    parentEntityMetadata: EntityMetadata

    Parent's entity metadata. Used in inheritance patterns.

    primaryColumns: ColumnMetadata[]

    Gets the primary columns.

    propertiesMap: ObjectLiteral

    Map of columns and relations of the entity.

    example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }. This method will create following object: { id: "id", counterEmbed: { count: "counterEmbed.count" }, category: "category" }

    relationCounts: RelationCountMetadata[]

    Entity's relation id metadatas.

    relationIds: RelationIdMetadata[]

    Entity's relation id metadatas.

    relations: RelationMetadata[]

    Relations of the entity, including relations that are coming from the embeddeds of this entity.

    relationsWithJoinColumns: RelationMetadata[]

    Gets only owner one-to-one and many-to-one relations.

    schema?: string

    Schema name. Used in Postgres and Sql Server.

    synchronize: boolean

    Indicates if schema will be synchronized for this entity or not.

    tableMetadataArgs: TableMetadataArgs

    Metadata arguments used to build this entity metadata.

    tableName: string

    Entity table name in the database. This is final table name of the entity. This name already passed naming strategy, and generated based on multiple criteria, including user table name and global table prefix.

    tableNameWithoutPrefix: string

    Gets the table name without global table prefix. When querying table you need a table name with prefix, but in some scenarios, for example when you want to name a junction table that contains names of two other tables, you may want a table name without prefix.

    tablePath: string

    Entity table path. Contains database name, schema name and table name. E.g. myDB.mySchema.myTable

    tableType: TableType

    Table type. Tables can be closure, junction, etc.

    target: string | Function

    Target class to which this entity metadata is bind. Note, that when using table inheritance patterns target can be different rather then table's target. For virtual tables which lack of real entity (like junction tables) target is equal to their table name.

    targetName: string

    Gets the name of the target.

    treeChildrenRelation?: RelationMetadata

    Tree children relation. Used only in tree-tables.

    treeLevelColumn?: ColumnMetadata

    Special column that stores tree level in tree entities.

    treeOptions?: ClosureTreeOptions

    Indicates if this entity is a tree, what options of tree it has.

    treeParentRelation?: RelationMetadata

    Tree parent relation. Used only in tree-tables.

    treeType?: TreeType

    Indicates if this entity is a tree, what type of tree it is.

    uniques: UniqueMetadata[]

    Entity's unique metadatas.

    updateDateColumn?: ColumnMetadata

    Gets entity column which contains an update date value.

    versionColumn?: ColumnMetadata

    Gets entity column which contains an entity version.

    withoutRowid?: boolean

    Enables Sqlite "WITHOUT ROWID" modifier for the "CREATE TABLE" statement

    方法

    • 返回 void

    • Compares two different entities by their ids. Returns true if they match, false otherwise.

      参数

      返回 boolean

    • Creates a new entity.

      参数

      • 可选queryRunner: QueryRunner
      • 可选options: { fromDeserializer?: boolean; pojo?: boolean }

      返回 any

    • Creates a special object - all columns and relations of the object (plus columns and relations from embeds) in a special format - { propertyName: propertyName }.

      example: Post{ id: number, name: string, counterEmbed: { count: number }, category: Category }. This method will create following object: { id: "id", counterEmbed: { count: "counterEmbed.count" }, category: "category" }

      返回 { [name: string]: any }

    • Ensures that given object is an entity id map. If given id is an object then it means its already id map. If given id isn't an object then it means its a value of the id column and it creates a new id map with this value and name of the primary column.

      参数

      • id: any

      返回 ObjectLiteral

    • Iterates through entity and finds and extracts all values from relations in the entity. If relation value is an array its being flattened.

      参数

      返回 [RelationMetadata, any, EntityMetadata][]

    • Finds columns with a given property path. Property path can match a relation, and relations can contain multiple columns.

      参数

      • propertyPath: string

      返回 ColumnMetadata[]

    • Finds column with a given database name.

      参数

      • databaseName: string

      返回 undefined | ColumnMetadata

    • Finds column with a given property name.

      参数

      • propertyName: string

      返回 undefined | ColumnMetadata

    • Finds column with a given property path.

      参数

      • propertyPath: string

      返回 undefined | ColumnMetadata

    • Finds column with a given property path. Does not search in relation unlike findColumnWithPropertyPath.

      参数

      • propertyPath: string

      返回 undefined | ColumnMetadata

    • Finds embedded with a given property path.

      参数

      • propertyPath: string

      返回 undefined | EmbeddedMetadata

    • In the case of SingleTableInheritance, find the correct metadata for a given value.

      参数

      • value: any

        The value to find the metadata for.

      返回 EntityMetadata

      The found metadata for the entity or the base metadata if no matching metadata was found in the whole inheritance tree.

    • Finds relation with the given property path.

      参数

      • propertyPath: string

      返回 undefined | RelationMetadata

    • Gets primary keys of the entity and returns them in a literal object. For example, for Post{ id: 1, title: "hello" } where id is primary it will return { id: 1 } For multiple primary keys it returns multiple keys in object. For primary keys inside embeds it returns complex object literal with keys in them.

      参数

      返回 undefined | ObjectLiteral

    • Creates a "mixed id map". If entity has multiple primary keys (ids) then it will return just regular id map, like what getEntityIdMap returns. But if entity has a single primary key then it will return just value of the id column of the entity, just value. This is called mixed id map.

      参数

      返回 undefined | ObjectLiteral

    • Checks if entity has any column which rely on returning data, e.g. columns with auto generated value, DEFAULT values considered as dependant of returning data. For example, if we need to have RETURNING after INSERT (or we need returned id for DBs not supporting RETURNING), it means we cannot execute bulk inserts in some cases.

      返回 ColumnMetadata[]

    • Checks if given entity / object contains ALL primary keys entity must have. Returns true if it contains all of them, false if at least one of them is not defined.

      参数

      返回 boolean

    • Checks if there is a column or relationship with a given property path.

      参数

      • propertyPath: string

      返回 boolean

    • Checks if there is an embedded with a given property path.

      参数

      • propertyPath: string

      返回 boolean

    • Checks if given entity has an id.

      参数

      返回 boolean

    • Checks if there is a relation with the given property path.

      参数

      • propertyPath: string

      返回 boolean

    • Returns an array of databaseNames mapped from provided propertyPaths

      参数

      • propertyPaths: string[]

      返回 ColumnMetadata[]

    • Registers a new column in the entity and recomputes all depend properties.

      参数

      • column: ColumnMetadata

      返回 void

    • Creates a property paths for a given entity.

      参数

      返回 string[]

    • Finds difference between two entity id maps. Returns items that exist in the first array and absent in the second array.

      参数

      返回 ObjectLiteral[]

    • Creates value map from the given values and columns. Examples of usages are primary columns map and join columns map.

      参数

      • entity: ObjectLiteral
      • columns: ColumnMetadata[]
      • 可选options: { skipNulls?: boolean }

      返回 undefined | ObjectLiteral