可选queryRunner: QueryRunner只读@instanceof只读connectionConnection used by this entity manager.
受保护plainPlain to object transformer used in create and merge operations.
可选 只读queryCustom query runner to be used for operations in this entity manager. Used only in non-global entity manager.
受保护repositoriesOnce created and then reused by repositories. Created as a future replacement for the #repositories to provide a bit more perf optimization.
受保护treeOnce created and then reused by repositories.
Return the AVG of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]Clears all the data from the given table (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 and copies all entity properties from this object into a new entity. Note that it copies only properties that present in entity schema.
可选plainObject: EntityLikeCreates a new entities and copies all entity properties from given objects into their new entities. Note that it copies only properties that present in entity schema.
可选plainObjects: EntityLike[]Creates a new query builder that can be used to build a SQL query.
可选queryRunner: QueryRunnerCreates a new query builder that can be used to build a SQL query.
可选queryRunner: QueryRunnerDecrements some column by provided value of the entities matched given conditions.
Deletes entities by a given condition(s). 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. Condition(s) cannot be empty.
Checks whether any entity exists with the given options.
可选options: FindManyOptions<Entity>Checks whether any entity exists with the given conditions.
Finds entities that match given find options.
可选options: FindManyOptions<Entity>Finds 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.
Finds 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 id. 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.
Gets entity mixed id.
Gets mongodb repository for the given entity class.
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.
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.
Checks if entity has an id.
Checks if entity of given schema name has an id.
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. You can execute bulk inserts using this method.
Return the MAX of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]Merges two entities into one new 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.
Executes raw SQL query and returns raw database results.
可选parameters: any[]Official docs for examples.
Recovers all given entities.
可选options: SaveOptionsRecovers all given entities.
可选options: SaveOptionsRecovers a given entity.
可选options: SaveOptionsReleases 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.
Removes a given entity from the database.
可选options: RemoveOptionsRemoves a given entity from the database.
可选options: RemoveOptionsRemoves a given entity from the database.
可选options: RemoveOptionsRemoves a given entity from the database.
可选options: RemoveOptionsRestores entities by a given condition(s). 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. Condition(s) cannot be empty.
Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.
可选options: SaveOptionsSaves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.
可选options: SaveOptionsSaves 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 condition(s). 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. Condition(s) cannot be empty.
Records the delete date of all given entities.
可选options: SaveOptionsRecords the delete date of a given entity.
可选options: SaveOptionsRecords the delete date of all given entities.
可选options: SaveOptionsRecords the delete date of a given entity.
可选options: SaveOptionsReturn the SUM of a column
可选where: FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]Wraps given function execution (and all operations made there) in a transaction. All database operations must be executed using provided entity manager.
Wraps given function execution (and all operations made there) in a transaction. All database operations must be executed using provided entity manager.
Updates entity partially. Entity can be found by a given condition(s). 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. Condition(s) cannot be empty.
Creates a new repository instance out of a given Repository and sets current EntityManager instance to it. Used to work with custom repositories in transactions.
Entity manager supposed to work with any entity, automatically find its repository and call its methods, whatever entity type are you passing.