Options
All
  • Public
  • Public/Protected
  • All
Menu

Base abstract entity for all entities, used in ActiveRecord patterns.

Hierarchy

  • BaseEntity

Index

Properties

Static Private Optional usedConnection

usedConnection: Connection

Connection used in all static methods of the BaseEntity.

Accessors

Static target

  • get target(): Function | string
  • Returns object that is managed by this repository. If this repository manages entity from schema, then it returns a name of that schema instead.

    Returns Function | string

Methods

hasId

  • hasId(): boolean
  • Checks if entity has an id. If entity composite compose ids, it will check them all.

    Returns boolean

reload

  • reload(): Promise<void>

remove

  • remove(): Promise<this>

save

  • save(): Promise<this>
  • Saves current entity in the database. If entity does not exist in the database then inserts, otherwise updates.

    Returns Promise<this>

Static clear

Static count

Static create

Static createQueryBuilder

Static delete

  • Deletes entities by a given criteria. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient DELETE query. Does not check if entity exist in the database.

    Type parameters

    Parameters

    Returns Promise<DeleteResult>

Static find

Static findAndCount

  • Finds entities that match given find options. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).

    Type parameters

    Parameters

    Returns Promise<[T[], number]>

  • Finds entities that match given conditions. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).

    Type parameters

    Parameters

    Returns Promise<[T[], number]>

Static findByIds

Static findOne

Static findOneOrFail

Static getId

Static getRepository

Static hasId

Static 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.

    Type parameters

    Parameters

    Returns Promise<InsertResult>

Static merge

Static 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.

    Note that given entity-like object must have an entity id / primary key to find entity by. Returns undefined if entity with given id was not found.

    Type parameters

    Parameters

    Returns Promise<T | undefined>

Static query

  • query<T>(this: ObjectType<T>, query: string, parameters?: any[]): Promise<any>
  • Executes a raw SQL query and returns a raw database results. Raw query execution is supported only by relational databases (MongoDB is not supported).

    Type parameters

    Parameters

    • this: ObjectType<T>
    • query: string
    • Optional parameters: any[]

    Returns Promise<any>

Static remove

Static save

Static update

  • Updates entity partially. Entity can be found by a given conditions. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient UPDATE query. Does not check if entity exist in the database.

    Type parameters

    Parameters

    Returns Promise<UpdateResult>

Static useConnection

Generated using TypeDoc