Options
All
  • Public
  • Public/Protected
  • All
Menu

A special EntityManager that includes import/export and load/save function that are unique to Sql.js.

Hierarchy

Index

Constructors

constructor

Properties

connection

connection: Connection

Connection used by this entity manager.

Private driver

driver: SqljsDriver

Protected plainObjectToEntityTransformer

plainObjectToEntityTransformer: PlainObjectToNewEntityTransformer = new PlainObjectToNewEntityTransformer()

Plain to object transformer used in create and merge operations.

Optional queryRunner

queryRunner: QueryRunner

Custom query runner to be used for operations in this entity manager. Used only in non-global entity manager.

Protected repositories

repositories: Repository<any>[] = []

Once created and then reused by en repositories.

Methods

clear

count

create

createQueryBuilder

decrement

delete

exportDatabase

  • exportDatabase(): Uint8Array

find

findAndCount

findByIds

findOne

findOneOrFail

getCustomRepository

  • getCustomRepository<T>(customRepository: ObjectType<T>): T

getId

  • getId(entity: any): any
  • getId(target: Function | string, entity: any): any

getMongoRepository

getRepository

  • Gets repository for the given entity class or name. If single database connection mode is used, then repository is obtained from the repository aggregator, where each repository is individually created for this entity manager. When single database connection is not used, repository is being obtained from the connection.

    Type parameters

    • Entity

    Parameters

    Returns Repository<Entity>

getTreeRepository

  • Gets tree repository for the given entity class or name. If single database connection mode is used, then repository is obtained from the repository aggregator, where each repository is individually created for this entity manager. When single database connection is not used, repository is being obtained from the connection.

    Type parameters

    • Entity

    Parameters

    Returns TreeRepository<Entity>

hasId

  • hasId(entity: any): boolean
  • hasId(target: Function | string, entity: any): boolean

increment

insert

  • Inserts a given entity into the database. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT query. Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted. You can execute bulk inserts using this method.

    Type parameters

    • Entity

    Parameters

    Returns Promise<InsertResult>

loadDatabase

  • loadDatabase(fileNameOrLocalStorageOrData: string | Uint8Array): void
  • Loads either the definition from a file (Node.js) or localstorage (browser) or uses the given definition to open a new database.

    Parameters

    • fileNameOrLocalStorageOrData: string | Uint8Array

    Returns void

merge

preload

  • Creates a new entity from the given plan javascript object. If entity already exist in the database, then it loads it (and everything related to it), replaces all values with the new ones from the given object and returns this new entity. This new entity is actually a loaded from the db entity with all properties replaced from the new object.

    Type parameters

    • Entity

    Parameters

    Returns Promise<Entity | undefined>

query

  • query(query: string, parameters?: any[]): Promise<any>

release

  • release(): Promise<void>
  • Releases all resources used by entity manager. This is used when entity manager is created with a single query runner, and this single query runner needs to be released after job with entity manager is done.

    Returns Promise<void>

remove

save

saveDatabase

  • saveDatabase(fileNameOrLocalStorage?: undefined | string): Promise<void>
  • Saves the current database to a file (Node.js) or localstorage (browser) if fileNameOrLocalStorage is not set options.location is used.

    Parameters

    • Optional fileNameOrLocalStorage: undefined | string

    Returns Promise<void>

transaction

  • transaction<T>(runInTransaction: function): Promise<T>
  • transaction<T>(isolationLevel: IsolationLevel, runInTransaction: function): Promise<T>

update

Generated using TypeDoc