Options
All
  • Public
  • Public/Protected
  • All
Menu

typeorm

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

AggregationCursorResult

AggregationCursorResult: any | void

ColumnMode

ColumnMode: "regular" | "virtual" | "createDate" | "updateDate" | "version" | "treeChildrenCount" | "treeLevel" | "objectId" | "array"

Kinda type of the column. Not a type in the database, but locally used type to determine what kind of column we are working with. For example, "primary" means that it will be a primary column, or "createDate" means that it will create a create date column.

ColumnType

ColumnType: WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SpatialColumnType | SimpleColumnType | BooleanConstructor | DateConstructor | NumberConstructor | StringConstructor

Any column type column can be.

Condition

Condition: object

Condition.

Type declaration

  • [key: string]: any
  • Optional $and?: (object | T[P] | object)[]
  • Optional $bitsAllClear?: Object
  • Optional $bitsAllSet?: Object
  • Optional $bitsAnyClear?: Object
  • Optional $bitsAnySet?: Object
  • Optional $elemMatch?: Object
  • Optional $eq?: T[P]
  • Optional $expr?: any
  • Optional $geoIntersects?: Object
  • Optional $geoWithin?: Object
  • Optional $gt?: T[P]
  • Optional $gte?: T[P]
  • Optional $in?: T[P][]
  • Optional $jsonSchema?: any
  • Optional $lt?: T[P]
  • Optional $lte?: T[P]
  • Optional $mod?: [number, number]
  • Optional $ne?: T[P]
  • Optional $near?: Object
  • Optional $nearSphere?: Object
  • Optional $nin?: T[P][]
  • Optional $not?: (object | T[P] | object)[] | T[P]
  • Optional $options?: string
  • Optional $or?: (object | T[P] | object)[]
  • Optional $regex?: RegExp
  • Optional $size?: number
  • Optional $text?: object
    • Optional $caseSensitive?: boolean
    • Optional $diacraticSensitive?: boolean
    • Optional $language?: string
    • $search: string
  • Optional $where?: Object

ConnectionOptions

ConnectionOptions is an interface with settings and options for specific connection. Options contain database and other connection-related settings. Consumer must provide connection options for each of your connections.

ContainedType

ContainedType: object | Function

CursorResult

CursorResult: any | void | boolean

DatabaseType

DatabaseType: "mysql" | "postgres" | "cockroachdb" | "mariadb" | "sqlite" | "cordova" | "react-native" | "nativescript" | "sqljs" | "oracle" | "mssql" | "mongodb" | "expo"

Database type.

DeepPartial

DeepPartial: object

Same as Partial but goes deeper and makes Partial all its properties and sub-properties.

Type declaration

DeferrableType

DeferrableType: "INITIALLY IMMEDIATE" | "INITIALLY DEFERRED"

DEFERRABLE type to be used to specify if foreign key constraints can be deferred.

EntityId

EntityId: string | number | Date | ObjectID

EventListenerType

EventListenerType: "after-load" | "before-insert" | "after-insert" | "before-update" | "after-update" | "before-remove" | "after-remove"

All types that entity listener can be.

FilterQuery

FilterQuery: object | object

FindConditions

FindConditions: object

Used for find operations.

Type declaration

FindOperatorType

FindOperatorType: "not" | "lessThan" | "lessThanOrEqual" | "moreThan" | "moreThanOrEqual" | "equal" | "between" | "in" | "any" | "isNull" | "like" | "raw"

List of types that FindOperator can be.

IsolationLevel

IsolationLevel: "READ UNCOMMITTED" | "READ COMMITTED" | "REPEATABLE READ" | "SERIALIZABLE"

LoggerOptions

LoggerOptions: boolean | "all" | ("query" | "schema" | "error" | "warn" | "info" | "log" | "migration")[]

Logging options.

ObjectType

ObjectType: object | Function

Represents some Type of the Object.

OnDeleteType

OnDeleteType: "RESTRICT" | "CASCADE" | "SET NULL" | "DEFAULT" | "NO ACTION"

ON_DELETE type to be used to specify delete strategy when some relation is being deleted from the database.

OnUpdateType

OnUpdateType: "RESTRICT" | "CASCADE" | "SET NULL" | "DEFAULT" | "NO ACTION"

ON_UPDATE type to be used to specify update strategy when some relation is being updated.

OrderByCondition

OrderByCondition: object

Special object that defines order condition for ORDER BY in sql.

Example: { "name": "ASC", "id": "DESC" }

Type declaration

  • [columnName: string]: "ASC" | "DESC" | object

PrimaryGeneratedColumnType

PrimaryGeneratedColumnType: "int" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "fixed" | "numeric" | "number" | "uuid"

Column types used for @PrimaryGeneratedColumn() decorator.

PropertyTypeFactory

PropertyTypeFactory: string | function

Contains the name of the property of the object, or the function that returns this name.

QueryDeepPartialEntity

QueryDeepPartialEntity: object

Make all properties in T optional. Deep version.

Type declaration

QueryPartialEntity

QueryPartialEntity: object

Make all properties in T optional

Type declaration

ReadConcernLevel

ReadConcernLevel: "local" | "available" | "majority" | "linearizable" | "snapshot"

RelationType

RelationType: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many"

All types that relation can be.

RelationTypeInFunction

RelationTypeInFunction: function | Function | string

Function that returns a type of the field. Returned value must be a class used on the relation.

SelectQueryBuilderOption

SelectQueryBuilderOption: "disable-global-order" | "create-pojo"

SimpleColumnType

SimpleColumnType: "simple-array" | "simple-json" | "simple-enum" | "bit" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array"

All other regular column types.

SpatialColumnType

SpatialColumnType: "geometry" | "geography"

Column types where spatial properties are used.

TableType

TableType: "regular" | "view" | "junction" | "closure" | "closure-junction" | "entity-child"

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

TreeType

TreeType: "adjacency-list" | "closure-table" | "nested-set" | "materialized-path"

Tree type. Specifies what table pattern will be used for the tree entity.

UpdateQuery

UpdateQuery: object

Type declaration

  • Optional $addToSet?: Partial<T> | object
  • Optional $bit?: object | object
  • Optional $currentDate?: object | object
  • Optional $each?: Partial<T> | object
  • Optional $inc?: object | object
  • Optional $max?: object | object
  • Optional $min?: object | object
  • Optional $mul?: object | object
  • Optional $pop?: object | object
  • Optional $pull?: Partial<T> | object
  • Optional $push?: Partial<T> | object
  • Optional $pushAll?: Partial<T> | object
  • Optional $rename?: object | object
  • Optional $set?: Partial<T> | object
  • Optional $setOnInsert?: Partial<T> | object
  • Optional $unset?: object | object

WithLengthColumnType

WithLengthColumnType: "character varying" | "varying character" | "char varying" | "nvarchar" | "national varchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "national char" | "varchar2" | "nvarchar2" | "raw" | "binary" | "varbinary" | "string"

Column types where column length is used.

WithPrecisionColumnType

WithPrecisionColumnType: "float" | "double" | "dec" | "decimal" | "fixed" | "numeric" | "real" | "double precision" | "number" | "datetime" | "datetime2" | "datetimeoffset" | "time" | "time with time zone" | "time without time zone" | "timestamp" | "timestamp without time zone" | "timestamp with time zone" | "timestamp with local time zone"

Column types where precision and scale properties are used.

WithWidthColumnType

WithWidthColumnType: "tinyint" | "smallint" | "mediumint" | "int" | "bigint"

Variables

Const chalk

chalk: any = require("chalk")

Const defaultContainer

defaultContainer: ContainerInterface = new (class implements ContainerInterface {private instances: { type: Function, object: any }[] = [];get<T>(someClass: ContainedType<T>): T {let instance = this.instances.find(i => i.type === someClass);if (!instance) {instance = { type: someClass, object: new (someClass as new() => T)()};this.instances.push(instance);}return instance.object;}})()

Container to be used by this library for inversion control. If container was not implicitly set then by default container simply creates a new instance of the given class.

Const exec

exec: any = require("child_process").exec

Const mkdirp

mkdirp: any = require("mkdirp")

Let userContainer

userContainer: ContainerInterface

Let userContainerOptions

userContainerOptions: UseContainerOptions | undefined

Const window

window: Window

Functions

AfterInsert

  • AfterInsert(): (Anonymous function)

AfterLoad

  • AfterLoad(): (Anonymous function)

AfterRemove

  • AfterRemove(): (Anonymous function)

AfterUpdate

  • AfterUpdate(): (Anonymous function)

Any

BeforeInsert

  • BeforeInsert(): (Anonymous function)

BeforeRemove

  • BeforeRemove(): (Anonymous function)

BeforeUpdate

  • BeforeUpdate(): (Anonymous function)

Between

Check

  • Check(expression: string): Function
  • Check(name: string, expression: string): Function
  • Creates a database check. Can be used on entity property or on entity. Can create checks with composite columns when used on entity.

    Parameters

    • expression: string

    Returns Function

  • Creates a database check. Can be used on entity property or on entity. Can create checks with composite columns when used on entity.

    Parameters

    • name: string
    • expression: string

    Returns Function

ChildEntity

  • ChildEntity(discriminatorValue?: any): (Anonymous function)
  • Special type of the table used in the single-table inherited tables.

    Parameters

    • Optional discriminatorValue: any

    Returns (Anonymous function)

Column

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved.

    Property in entity can be marked as Embedded, and on persist all columns from the embedded are mapped to the single table of the entity where Embedded is used. And on hydration all columns which supposed to be in the embedded will be mapped to it from the single table.

    Parameters

    • type: function
        • (type?: any): Function
        • Parameters

          • Optional type: any

          Returns Function

    • Optional options: ColumnEmbeddedOptions

    Returns Function

CreateDateColumn

  • This column will store a creation date of the inserted object. Creation date is generated and inserted only once, at the first time when you create an object, the value is inserted into the table, and is never touched again.

    Parameters

    Returns Function

Entity

  • This decorator is used to mark classes that will be an entity (table or document depend on database type). Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.

    Parameters

    Returns Function

  • This decorator is used to mark classes that will be an entity (table or document depend on database type). Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.

    Parameters

    Returns Function

EntityRepository

  • EntityRepository(entity?: Function): Function
  • Used to declare a class as a custom repository. Custom repository can manage some specific entity or just be generic. Custom repository optionally can extend AbstractRepository, Repository or TreeRepository.

    Parameters

    • Optional entity: Function

    Returns Function

Equal

EventSubscriber

  • EventSubscriber(): (Anonymous function)
  • Classes decorated with this decorator will listen to ORM events and their methods will be triggered when event occurs. Those classes must implement EventSubscriberInterface interface.

    Returns (Anonymous function)

Exclusion

  • Exclusion(expression: string): Function
  • Exclusion(name: string, expression: string): Function
  • Creates a database exclusion. Can be used on entity. Can create exclusions with composite columns when used on entity.

    Parameters

    • expression: string

    Returns Function

  • Creates a database exclusion. Can be used on entity. Can create exclusions with composite columns when used on entity.

    Parameters

    • name: string
    • expression: string

    Returns Function

Generated

  • Generated(strategy?: "increment" | "uuid" | "rowid"): Function
  • Marks a column to generate a value on entity insertion. There are three types of generation strategy - increment, uuid and rowid (cockroachdb only). Increment uses a number which increases by one on each insertion. Uuid generates a special UUID token. Rowid supports only in CockroachDB and uses unique_rowid() function

    Note, some databases do not support non-primary generation columns.

    Parameters

    • Default value strategy: "increment" | "uuid" | "rowid" = "increment"

    Returns Function

In

Index

  • Index(options?: IndexOptions): Function
  • Index(name: string, options?: IndexOptions): Function
  • Index(name: string, options: object): Function
  • Index(name: string, fields: string[], options?: IndexOptions): Function
  • Index(fields: string[], options?: IndexOptions): Function
  • Index(fields: function, options?: IndexOptions): Function
  • Index(name: string, fields: function, options?: IndexOptions): Function
  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    Returns Function

  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    Returns Function

  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    • name: string
    • options: object
      • synchronize: false

    Returns Function

  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    • name: string
    • fields: string[]
    • Optional options: IndexOptions

    Returns Function

  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    Returns Function

  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    • fields: function
        • (object?: any): any[] | object
        • Parameters

          • Optional object: any

          Returns any[] | object

    • Optional options: IndexOptions

    Returns Function

  • Creates a database index. Can be used on entity property or on entity. Can create indices with composite columns when used on entity.

    Parameters

    • name: string
    • fields: function
        • (object?: any): any[] | object
        • Parameters

          • Optional object: any

          Returns any[] | object

    • Optional options: IndexOptions

    Returns Function

IsNull

JoinColumn

  • JoinColumn decorator used on one-to-one relations to specify owner side of relationship. It also can be used on both one-to-one and many-to-one relations to specify custom column name or custom referenced column.

    Returns Function

  • JoinColumn decorator used on one-to-one relations to specify owner side of relationship. It also can be used on both one-to-one and many-to-one relations to specify custom column name or custom referenced column.

    Parameters

    Returns Function

  • JoinColumn decorator used on one-to-one relations to specify owner side of relationship. It also can be used on both one-to-one and many-to-one relations to specify custom column name or custom referenced column.

    Parameters

    Returns Function

JoinTable

  • JoinTable decorator is used in many-to-many relationship to specify owner side of relationship. Its also used to set a custom junction table's name, column names and referenced columns.

    Returns Function

  • JoinTable decorator is used in many-to-many relationship to specify owner side of relationship. Its also used to set a custom junction table's name, column names and referenced columns.

    Parameters

    Returns Function

  • JoinTable decorator is used in many-to-many relationship to specify owner side of relationship. Its also used to set a custom junction table's name, column names and referenced columns.

    Parameters

    Returns Function

LessThan

LessThanOrEqual

Like

ManyToMany

  • ManyToMany<T>(typeFunction: function, options?: RelationOptions): Function
  • ManyToMany<T>(typeFunction: function, inverseSide?: string | function, options?: RelationOptions): Function
  • Many-to-many is a type of relationship when Entity1 can have multiple instances of Entity2, and Entity2 can have multiple instances of Entity1. To achieve it, this type of relation creates a junction table, where it storage entity1 and entity2 ids. This is owner side of the relationship.

    Type parameters

    • T

    Parameters

    Returns Function

  • Many-to-many is a type of relationship when Entity1 can have multiple instances of Entity2, and Entity2 can have multiple instances of Entity1. To achieve it, this type of relation creates a junction table, where it storage entity1 and entity2 ids. This is owner side of the relationship.

    Type parameters

    • T

    Parameters

    • typeFunction: function
    • Optional inverseSide: string | function
    • Optional options: RelationOptions

    Returns Function

ManyToOne

  • ManyToOne<T>(typeFunction: function, options?: RelationOptions): Function
  • ManyToOne<T>(typeFunction: function, inverseSide?: string | function, options?: RelationOptions): Function
  • Many-to-one relation allows to create type of relation when Entity1 can have single instance of Entity2, but Entity2 can have a multiple instances of Entity1. Entity1 is an owner of the relationship, and storages Entity2 id on its own side.

    Type parameters

    • T

    Parameters

    Returns Function

  • Many-to-one relation allows to create type of relation when Entity1 can have single instance of Entity2, but Entity2 can have a multiple instances of Entity1. Entity1 is an owner of the relationship, and storages Entity2 id on its own side.

    Type parameters

    • T

    Parameters

    • typeFunction: function
    • Optional inverseSide: string | function
    • Optional options: RelationOptions

    Returns Function

MoreThan

MoreThanOrEqual

Not

ObjectIdColumn

OneToMany

  • OneToMany<T>(typeFunction: function, inverseSide: string | function, options?: RelationOptions): Function
  • One-to-many relation allows to create type of relation when Entity2 can have multiple instances of Entity1. Entity1 have only one Entity2. Entity1 is an owner of the relationship, and storages Entity2 id on its own side.

    Type parameters

    • T

    Parameters

    Returns Function

OneToOne

  • OneToOne<T>(typeFunction: function, options?: RelationOptions): Function
  • OneToOne<T>(typeFunction: function, inverseSide?: string | function, options?: RelationOptions): Function
  • One-to-one relation allows to create direct relation between two entities. Entity1 have only one Entity2. Entity1 is an owner of the relationship, and storages Entity1 id on its own side.

    Type parameters

    • T

    Parameters

    Returns Function

  • One-to-one relation allows to create direct relation between two entities. Entity1 have only one Entity2. Entity1 is an owner of the relationship, and storages Entity1 id on its own side.

    Type parameters

    • T

    Parameters

    • typeFunction: function
    • Optional inverseSide: string | function
    • Optional options: RelationOptions

    Returns Function

PrimaryColumn

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved. Primary columns also creates a PRIMARY KEY for this column in a db.

    Parameters

    Returns Function

  • Column decorator is used to mark a specific class property as a table column. Only properties decorated with this decorator will be persisted to the database when entity be saved. Primary columns also creates a PRIMARY KEY for this column in a db.

    Parameters

    Returns Function

PrimaryGeneratedColumn

Raw

RelationCount

  • RelationCount<T>(relation: string | function, alias?: string, queryBuilderFactory?: function): Function

RelationId

  • RelationId<T>(relation: string | function, alias?: string, queryBuilderFactory?: function): Function

TableInheritance

  • TableInheritance(options?: object): (Anonymous function)

Transaction

  • Transaction(connectionName?: string): MethodDecorator
  • Transaction(options?: TransactionOptions): MethodDecorator
  • Wraps some method into the transaction.

    Method result will return a promise if this decorator applied. All database operations in the wrapped method should be executed using entity managed passed as a first parameter into the wrapped method.

    If you want to control at what position in your method parameters entity manager should be injected, then use @TransactionEntityManager() decorator.

    If you want to use repositories instead of bare entity manager, then use @TransactionRepository() decorator.

    Parameters

    • Optional connectionName: string

    Returns MethodDecorator

  • Parameters

    • Optional options: TransactionOptions

    Returns MethodDecorator

TransactionManager

  • TransactionManager(): Function

TransactionRepository

  • TransactionRepository(entityType?: Function): ParameterDecorator

Tree

  • Marks entity to work like a tree. Tree pattern that will be used for the tree entity should be specified.

    treeparent

    decorator must be used in tree entities. TreeRepository can be used to manipulate with tree entities.

    Parameters

    Returns Function

TreeChildren

  • TreeChildren(options?: object): Function
  • Marks a entity property as a children of the tree. "Tree children" will contain all children (bind) of this entity.

    Parameters

    • Optional options: object
      • Optional cascade?: boolean | ("insert" | "update" | "remove")[]

    Returns Function

TreeLevelColumn

  • TreeLevelColumn(): Function

TreeParent

  • TreeParent(): Function
  • Marks a entity property as a parent of the tree. "Tree parent" indicates who owns (is a parent) of this entity in tree structure.

    Returns Function

Unique

  • Unique(name: string, fields: string[]): Function
  • Unique(fields: string[]): Function
  • Unique(fields: function): Function
  • Unique(name: string, fields: function): Function
  • Composite unique constraint must be set on entity classes and must specify entity's fields to be unique.

    Parameters

    • name: string
    • fields: string[]

    Returns Function

  • Composite unique constraint must be set on entity classes and must specify entity's fields to be unique.

    Parameters

    • fields: string[]

    Returns Function

  • Composite unique constraint must be set on entity classes and must specify entity's fields to be unique.

    Parameters

    • fields: function
        • (object?: any): any[] | object
        • Parameters

          • Optional object: any

          Returns any[] | object

    Returns Function

  • Composite unique constraint must be set on entity classes and must specify entity's fields to be unique.

    Parameters

    • name: string
    • fields: function
        • (object?: any): any[] | object
        • Parameters

          • Optional object: any

          Returns any[] | object

    Returns Function

UpdateDateColumn

VersionColumn

  • This column will store a number - version of the entity. Every time your entity will be persisted, this number will be increased by one - so you can organize visioning and update strategies of your entity.

    Parameters

    Returns Function

ViewColumn

  • ViewColumn(): Function

ViewEntity

  • This decorator is used to mark classes that will be an entity view. Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.

    Parameters

    Returns Function

  • This decorator is used to mark classes that will be an entity view. Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.

    Parameters

    Returns Function

abbreviate

  • abbreviate(str: string, abbrLettersCount?: number): string
  • Builds abbreviated string from given string;

    Parameters

    • str: string
    • Default value abbrLettersCount: number = 1

    Returns string

camelCase

  • camelCase(str: string, firstCapital?: boolean): string

createConnection

  • Creates a new connection and registers it in the manager. Only one connection from ormconfig will be created (name "default" or connection without name).

    If connection options were not specified, then it will try to create connection automatically, based on content of ormconfig (json/js/yml/xml/env) file or environment variables. Only one connection from ormconfig will be created (name "default" or connection without name).

    Returns Promise<Connection>

  • Creates a new connection from the ormconfig file with a given name.

    If connection options were not specified, then it will try to create connection automatically, based on content of ormconfig (json/js/yml/xml/env) file or environment variables. Only one connection from ormconfig will be created (name "default" or connection without name).

    Parameters

    • name: string

    Returns Promise<Connection>

  • Creates a new connection and registers it in the manager.

    If connection options were not specified, then it will try to create connection automatically, based on content of ormconfig (json/js/yml/xml/env) file or environment variables. Only one connection from ormconfig will be created (name "default" or connection without name).

    Parameters

    Returns Promise<Connection>

createConnections

  • Creates new connections and registers them in the manager.

    If connection options were not specified, then it will try to create connection automatically, based on content of ormconfig (json/js/yml/xml/env) file or environment variables. All connections from the ormconfig will be created.

    Parameters

    Returns Promise<Connection[]>

createDFS

  • createDFS(edges: any, leavesOnly: any, result: any): DFS
  • Helper for creating a Depth-First-Search on a set of edges.

    Detects cycles and throws an Error if one is detected.

    Parameters

    • edges: any

      The set of edges to DFS through

    • leavesOnly: any

      Whether to only return "leaf" nodes (ones who have no edges)

    • result: any

      An array in which the results will be populated

    Returns DFS

createQueryBuilder

  • createQueryBuilder<Entity>(entityClass?: ObjectType<Entity> | string, alias?: string, connectionName?: string): SelectQueryBuilder<Entity>
  • Creates a new query builder.

    Type parameters

    • Entity

    Parameters

    • Optional entityClass: ObjectType<Entity> | string
    • Optional alias: string
    • Default value connectionName: string = "default"

    Returns SelectQueryBuilder<Entity>

getConnection

  • getConnection(connectionName?: string): Connection
  • Gets connection from the connection manager. If connection name wasn't specified, then "default" connection will be retrieved.

    Parameters

    • Default value connectionName: string = "default"

    Returns Connection

getConnectionManager

getConnectionOptions

  • Reads connection options stored in ormconfig configuration file.

    Parameters

    • Default value connectionName: string = "default"

    Returns Promise<ConnectionOptions>

getCustomRepository

  • getCustomRepository<T>(customRepository: ObjectType<T>, connectionName?: string): T
  • Gets tree repository for the given entity class.

    Type parameters

    • T

    Parameters

    • customRepository: ObjectType<T>
    • Default value connectionName: string = "default"

    Returns T

getFromContainer

  • Gets the IOC container used by this library.

    Type parameters

    • T

    Parameters

    Returns T

getManager

  • Gets entity manager from the connection. If connection name wasn't specified, then "default" connection will be retrieved.

    Parameters

    • Default value connectionName: string = "default"

    Returns EntityManager

getMetadataArgsStorage

getMongoManager

  • Gets MongoDB entity manager from the connection. If connection name wasn't specified, then "default" connection will be retrieved.

    Parameters

    • Default value connectionName: string = "default"

    Returns MongoEntityManager

getMongoRepository

  • Gets mongodb repository for the given entity class or name.

    Type parameters

    • Entity

    Parameters

    • entityClass: ObjectType<Entity> | string
    • Default value connectionName: string = "default"

    Returns MongoRepository<Entity>

getRepository

  • Gets repository for the given entity class.

    Type parameters

    • Entity

    Parameters

    • entityClass: ObjectType<Entity> | EntitySchema<Entity> | string
    • Default value connectionName: string = "default"

    Returns Repository<Entity>

getSqljsManager

  • Gets Sqljs entity manager from connection name. "default" connection is used, when no name is specified. Only works when Sqljs driver is used.

    Parameters

    • Default value connectionName: string = "default"

    Returns SqljsEntityManager

getTreeRepository

  • Gets tree repository for the given entity class.

    Type parameters

    • Entity

    Parameters

    • entityClass: ObjectType<Entity> | string
    • Default value connectionName: string = "default"

    Returns TreeRepository<Entity>

importClassesFromDirectories

  • importClassesFromDirectories(directories: string[], formats?: string[]): Function[]
  • Loads all exported classes from the given directory.

    Parameters

    • directories: string[]
    • Default value formats: string[] = [".js", ".ts"]

    Returns Function[]

importJsonsFromDirectories

  • importJsonsFromDirectories(directories: string[], format?: string): any[]

shorten

  • Shorten a given input. Useful for RDBMS imposing a limit on the maximum length of aliases and column names in SQL queries.

    example

    // returns: "UsShCa__orde__mark__dire" shorten('UserShoppingCart__order__market__director')

    // returns: "cat_wit_ver_lon_nam_pos_wit_ver_lon_nam_pos_wit_ver_lon_nam" shorten( 'category_with_very_long_name_posts_with_very_long_name_post_with_very_long_name', { separator: '_', segmentLength: 3 } )

    // equals: UsShCa__orde__mark_market_id ${shorten('UserShoppingCart__order__market')}_market_id

    Parameters

    • input: string

      String to be shortened.

    • Default value options: IShortenOptions = {}

      Default to 4 for segments length, 2 for terms length, '__' as a separator.

    Returns string

    Shortened input.

snakeCase

  • snakeCase(str: string): string

titleCase

  • titleCase(str: string): string

useContainer

Generated using TypeDoc