Skip to main content

NexusDataSource

A TypeORM data source for ISP Nexus modules.

Extends​

  • DataSource

Implements​

  • AsyncDisposable
  • AsyncInitializable

Constructors​

new NexusDataSource()​

new NexusDataSource(options): NexusDataSource

Parameters​

ParameterType
optionsNexusDataSourceConfig

Returns​

NexusDataSource

Overrides​

DataSource.constructor

Properties​

@instanceof​

readonly @instanceof: symbol;

Inherited from​

DataSource.@instanceof


driver​

driver: SpatiaLiteDriver;

Database driver used by this connection.

Overrides​

DataSource.driver


entityMetadatas​

readonly entityMetadatas: EntityMetadata[];

All entity metadatas that are registered for this connection.

Inherited from​

DataSource.entityMetadatas


entityMetadatasMap​

readonly entityMetadatasMap: Map<EntityTarget<any>, EntityMetadata>;

All entity metadatas that are registered for this connection. This is a copy of #.entityMetadatas property -> used for more performant searches.

Inherited from​

DataSource.entityMetadatasMap


isInitialized​

readonly isInitialized: boolean;

Indicates if DataSource is initialized or not.

Inherited from​

DataSource.isInitialized


logger​

logger: Logger;

Logger used to log orm events.

Inherited from​

DataSource.logger


manager​

readonly manager: EntityManager;

EntityManager of this connection.

Inherited from​

DataSource.manager


metadataTableName​

readonly metadataTableName: string;

Name for the metadata table

Inherited from​

DataSource.metadataTableName


migrations​

readonly migrations: MigrationInterface[];

Migration instances that are registered for this connection.

Inherited from​

DataSource.migrations


name​

readonly name: string;

Connection name.

Deprecated​

we don't need names anymore since we are going to drop all related methods relying on this property.

Inherited from​

DataSource.name


namingStrategy​

namingStrategy: NamingStrategyInterface;

Naming strategy used in the connection.

Inherited from​

DataSource.namingStrategy


options​

readonly options: DataSourceOptions;

Connection options.

Inherited from​

DataSource.options


pragmas​

readonly pragmas: SQLitePragmaRecord;

queryResultCache?​

optional queryResultCache: QueryResultCache;

Used to work with query result cache.

Inherited from​

DataSource.queryResultCache


relationIdLoader​

readonly relationIdLoader: RelationIdLoader;

Inherited from​

DataSource.relationIdLoader


relationLoader​

readonly relationLoader: RelationLoader;

Used to load relations and work with lazy relations.

Inherited from​

DataSource.relationLoader


storagePath​

readonly storagePath: PathBuilder<string> | ":memory:";

subscribers​

readonly subscribers: EntitySubscriberInterface<any>[];

Entity subscriber instances that are registered for this connection.

Inherited from​

DataSource.subscribers


kInit​

static kInit: symbol;

Accessors​

isConnected​

get isConnected(): boolean

Indicates if DataSource is initialized or not. * *

Deprecated​

use .isInitialized instead

Returns​

boolean

Inherited from​

DataSource.isConnected


mongoManager​

get mongoManager(): MongoEntityManager

Gets the mongodb entity manager that allows to perform mongodb-specific repository operations with any entity in this connection.

Available only in mongodb connections.

Returns​

MongoEntityManager

Inherited from​

DataSource.mongoManager


sqljsManager​

get sqljsManager(): SqljsEntityManager

Gets a sql.js specific Entity Manager that allows to perform special load and save operations

Available only in connection with the sqljs driver.

Returns​

SqljsEntityManager

Inherited from​

DataSource.sqljsManager

Methods​

[asyncDispose]()​

asyncDispose: Promise<void>

Returns​

Promise<void>

Implementation of​

AsyncDisposable.[asyncDispose]


[asyncInit]()​

asyncInit: Promise<NexusDataSource>

Returns​

Promise<NexusDataSource>

Implementation of​

AsyncInitializable.[asyncInit]


attach()​

attach(
databasePath,
schemaName,
mode): Promise<void>

Attach a database to the current connection.

Parameters​

ParameterTypeDefault value
databasePathPathBuilderLikeundefined
schemaNamePathBuilderLikeundefined
mode"ro" | "rw" | "rwc""ro"

Returns​

Promise<void>


buildMetadatas()​

protected buildMetadatas(): Promise<void>

Builds metadatas for all registered classes inside this connection.

Returns​

Promise<void>

Inherited from​

DataSource.buildMetadatas


close()​

close(): Promise<void>

Closes connection with the database. Once connection is closed, you cannot use repositories or perform any operations except opening connection again.

Returns​

Promise<void>

Deprecated​

use .destroy method instead

Inherited from​

DataSource.close


connect()​

connect(): Promise<NexusDataSource>

Performs connection to the database. This method should be called once on application bootstrap. This method not necessarily creates database connection (depend on database type), but it also can setup a connection pool with database to use.

Returns​

Promise<NexusDataSource>

Deprecated​

use .initialize method instead

Inherited from​

DataSource.connect


createEntityManager()​

createEntityManager(queryRunner?): EntityManager

Creates an Entity Manager for the current connection with the help of the EntityManagerFactory.

Parameters​

ParameterType
queryRunner?QueryRunner

Returns​

EntityManager

Inherited from​

DataSource.createEntityManager


createQueryBuilder()​

createQueryBuilder(entityClass, alias, queryRunner)​

createQueryBuilder<Entity>(
entityClass,
alias,
queryRunner?): SelectQueryBuilder<Entity>

Creates a new query builder that can be used to build a SQL query.

Type Parameters​
Type Parameter
Entity extends ObjectLiteral
Parameters​
ParameterType
entityClassEntityTarget<Entity>
aliasstring
queryRunner?QueryRunner
Returns​

SelectQueryBuilder<Entity>

Inherited from​

DataSource.createQueryBuilder

createQueryBuilder(queryRunner)​

createQueryBuilder(queryRunner?): SelectQueryBuilder<any>

Creates a new query builder that can be used to build a SQL query.

Parameters​
ParameterType
queryRunner?QueryRunner
Returns​

SelectQueryBuilder<any>

Inherited from​

DataSource.createQueryBuilder


createQueryRunner()​

createQueryRunner(mode?): QueryRunner

Creates a query runner used for perform queries on a single database connection. Using query runners you can control your queries to execute using single database connection and manually control your database transaction.

Mode is used in replication mode and indicates whatever you want to connect to master database or any of slave databases. If you perform writes you must use master database, if you perform reads you can use slave databases.

Parameters​

ParameterType
mode?ReplicationMode

Returns​

QueryRunner

Inherited from​

DataSource.createQueryRunner


defaultReplicationModeForReads()​

defaultReplicationModeForReads(): ReplicationMode

Get the replication mode SELECT queries should use for this datasource by default

Returns​

ReplicationMode

Inherited from​

DataSource.defaultReplicationModeForReads


destroy()​

destroy(): Promise<void>

Closes connection with the database. Once connection is closed, you cannot use repositories or perform any operations except opening connection again.

Returns​

Promise<void>

Inherited from​

DataSource.destroy


dispose()​

dispose(): Promise<void>

Returns​

Promise<void>


dropDatabase()​

dropDatabase(): Promise<void>

Drops the database and all its data. Be careful with this method on production since this method will erase all your database tables and their data. Can be used only after connection to the database is established.

Returns​

Promise<void>

Inherited from​

DataSource.dropDatabase


findMetadata()​

protected findMetadata(target): undefined | EntityMetadata

Finds exist entity metadata by the given entity class, target name or table name.

Parameters​

ParameterType
targetEntityTarget<any>

Returns​

undefined | EntityMetadata

Inherited from​

DataSource.findMetadata


getCustomRepository()​

getCustomRepository<T>(customRepository): T

Gets custom entity repository marked with

Type Parameters​

Type Parameter
T

Parameters​

ParameterType
customRepositoryObjectType<T>

Returns​

T

Deprecated​

use Repository.extend function to create a custom repository

Inherited from​

DataSource.getCustomRepository


getManyToManyMetadata()​

getManyToManyMetadata(entityTarget, relationPropertyPath): undefined | EntityMetadata

Gets entity metadata of the junction table (many-to-many table).

Parameters​

ParameterType
entityTargetEntityTarget<any>
relationPropertyPathstring

Returns​

undefined | EntityMetadata

Inherited from​

DataSource.getManyToManyMetadata


getMetadata()​

getMetadata(target): EntityMetadata

Gets entity metadata for the given entity class or schema name.

Parameters​

ParameterType
targetEntityTarget<any>

Returns​

EntityMetadata

Inherited from​

DataSource.getMetadata


getMongoRepository()​

getMongoRepository<Entity>(target): MongoRepository<Entity>

Gets mongodb-specific repository for the given entity class or name. Works only if connection is mongodb-specific.

Type Parameters​

Type Parameter
Entity extends ObjectLiteral

Parameters​

ParameterType
targetEntityTarget<Entity>

Returns​

MongoRepository<Entity>

Inherited from​

DataSource.getMongoRepository


getRepository()​

getRepository<Entity>(target): Repository<Entity>

Gets repository for the given entity.

Type Parameters​

Type Parameter
Entity extends ObjectLiteral

Parameters​

ParameterType
targetEntityTarget<Entity>

Returns​

Repository<Entity>

Inherited from​

DataSource.getRepository


getTreeRepository()​

getTreeRepository<Entity>(target): TreeRepository<Entity>

Gets tree repository for the given entity class or name. Only tree-type entities can have a TreeRepository, like ones decorated with

Type Parameters​

Type Parameter
Entity extends ObjectLiteral

Parameters​

ParameterType
targetEntityTarget<Entity>

Returns​

TreeRepository<Entity>

Inherited from​

DataSource.getTreeRepository


hasMetadata()​

hasMetadata(target): boolean

Checks if entity metadata exist for the given entity class, target name or table name.

Parameters​

ParameterType
targetEntityTarget<any>

Returns​

boolean

Inherited from​

DataSource.hasMetadata


initialize()​

initialize(ignitionKey?): Promise<NexusDataSource>

Parameters​

ParameterType
ignitionKey?symbol

Returns​

Promise<NexusDataSource>

Deprecated​

Use ready or Symbol.asyncInit instead.

Overrides​

DataSource.initialize


query()​

query<T>(
query,
parameters?,
queryRunner?): Promise<T>

Executes raw SQL query and returns raw database results.

Type Parameters​

Type ParameterDefault type
Tany

Parameters​

ParameterType
querystring
parameters?any[]
queryRunner?QueryRunner

Returns​

Promise<T>

Inherited from​

DataSource.query


ready()​

ready(): Promise<NexusDataSource>

Alias for the AsyncInitSymbol method.

Returns​

Promise<NexusDataSource>

Implementation of​

AsyncInitializable.ready


runMigrations()​

runMigrations(options?): Promise<Migration[]>

Runs all pending migrations. Can be used only after connection to the database is established.

Parameters​

ParameterType
options?object
options.fake?boolean
options.transaction?"none" | "all" | "each"

Returns​

Promise<Migration[]>

Inherited from​

DataSource.runMigrations


setOptions()​

setOptions(options): this

Updates current connection options with provided options.

Parameters​

ParameterType
optionsPartial<DataSourceOptions>

Returns​

this

Inherited from​

DataSource.setOptions


showMigrations()​

showMigrations(): Promise<boolean>

Lists all migrations and whether they have been run. Returns true if there are pending migrations

Returns​

Promise<boolean>

Inherited from​

DataSource.showMigrations


synchronize()​

synchronize(dropBeforeSync?): Promise<void>

Creates database schema for all entities registered in this connection. Can be used only after connection to the database is established.

Parameters​

ParameterTypeDescription
dropBeforeSync?booleanIf set to true then it drops the database with all its tables and data

Returns​

Promise<void>

Inherited from​

DataSource.synchronize


tableInfo()​

tableInfo<T>(tableName): Promise<ColumnInfo<T>[]>

Query the column information for a table.

Type Parameters​

Type ParameterDefault type
T extends stringstring

Parameters​

ParameterType
tableNamestring

Returns​

Promise<ColumnInfo<T>[]>


toString()​

toString(): string

Returns a string representation of an object.

Returns​

string


transaction()​

transaction(runInTransaction)​

transaction<T>(runInTransaction): Promise<T>

Wraps given function execution (and all operations made there) into a transaction. All database operations must be executed using provided entity manager.

Type Parameters​
Type Parameter
T
Parameters​
ParameterType
runInTransaction(entityManager) => Promise<T>
Returns​

Promise<T>

Inherited from​

DataSource.transaction

transaction(isolationLevel, runInTransaction)​

transaction<T>(isolationLevel, runInTransaction): Promise<T>
Type Parameters​
Type Parameter
T
Parameters​
ParameterType
isolationLevelIsolationLevel
runInTransaction(entityManager) => Promise<T>
Returns​

Promise<T>

Inherited from​

DataSource.transaction


undoLastMigration()​

undoLastMigration(options?): Promise<void>

Reverts last executed migration. Can be used only after connection to the database is established.

Parameters​

ParameterType
options?object
options.fake?boolean
options.transaction?"none" | "all" | "each"

Returns​

Promise<void>

Inherited from​

DataSource.undoLastMigration


vacuum()​

vacuum(): Promise<void>

Perform a VACUUM operation on the database.

Returns​

Promise<void>