可选queryRunner: QueryRunner只读managerEntity Manager used by this repository.
可选 只读queryQuery runner provider used for this repository.
只读targetEntity target that is managed by this repository. If this repository manages entity from schema, then it returns a name of that schema instead.
Entity metadata of the entity current repository manages.
Return the AVG of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]Clears all the data from the given table/collection (truncates/drops it).
Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
Counts entities that match given options. Useful for pagination.
可选options: FindManyOptions<Entity>Counts entities that match given conditions. Useful for pagination.
Creates a new entity instance.
Creates new entities and copies all entity properties from given objects into their new entities. Note that it copies only properties that are present in entity schema.
Creates a new entity instance and copies all entity properties from this object into a new entity. Note that it copies only properties that are present in entity schema.
Creates a query builder used to get ancestors of the entities in the tree.
Creates a query builder used to get descendants of the entities in a tree.
Creates a new query builder that can be used to build a SQL query.
可选alias: string可选queryRunner: QueryRunnerDecrements some column by provided value of the entities matched given conditions.
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.
Checks whether any entity exists that matches the given options.
可选options: FindManyOptions<Entity>Checks whether any entity exists that matches the given options.
可选options: FindManyOptions<Entity>Checks whether any entity exists that matches the given conditions.
Extends repository with provided functions.
Finds entities that match given find options.
可选options: FindManyOptions<Entity>Gets all parents (ancestors) of the given entity. Returns them all in a flat array.
可选options: FindTreeOptionsGets all parents (ancestors) of the given entity. Returns them in a tree - nested into each other.
可选options: FindTreeOptionsFinds entities that match given find options. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).
可选options: FindManyOptions<Entity>Finds entities that match given WHERE conditions. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).
Finds entities that match given find options.
Finds entities with ids. Optionally find options or conditions can be applied.
Gets all children (descendants) of the given entity. Returns them all in a flat array.
可选options: FindTreeOptionsGets all children (descendants) of the given entity. Returns them in a tree - nested into each other.
可选options: FindTreeOptionsFinds first entity by a given find options. If entity was not found in the database - returns null.
Finds first entity that matches given where condition. If entity was not found in the database - returns null.
Finds first entity that matches given where condition. If entity was not found in the database - rejects with error.
Finds first entity by a given find options. If entity was not found in the database - rejects with error.
Roots are entities that have no ancestors. Finds them all.
可选options: FindTreeOptionsChecks if entity has an id. If entity composite compose ids, it will check them all.
Increments some column by provided value of the entities matched given conditions.
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.
Return the MAX of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]Merges multiple entities (or entity-like objects) into a given entity.
Return the MIN of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]Creates a new entity from the given plain 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.
Executes a raw SQL query and returns a raw database results. Raw query execution is supported only by relational databases (MongoDB is not supported).
可选parameters: any[]Official docs for examples.
Recovers all given entities in the database.
Recovers all given entities in the database.
可选options: SaveOptionsRecovers a given entity in the database.
Recovers a given entity in the database.
可选options: SaveOptionsRemoves a given entities from the database.
可选options: RemoveOptionsRemoves a given entity from the database.
可选options: RemoveOptionsRestores entities by a given criteria. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient SOFT-DELETE query. Does not check if entity exist in the database.
Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.
Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.
可选options: SaveOptionsSaves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.
Saves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.
可选options: SaveOptionsRecords the delete date of entities by a given criteria. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient SOFT-DELETE query. Does not check if entity exist in the database.
Records the delete date of all given entities.
Records the delete date of all given entities.
可选options: SaveOptionsRecords the delete date of a given entity.
Records the delete date of a given entity.
可选options: SaveOptionsReturn the SUM of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]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.
Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
Repository with additional functions to work with trees.
参阅
Repository