Skip to content

@142vip.nest typeorm.类.MongoEntityManager

mmdapl edited this page Oct 8, 2026 · 1 revision

API 参考 / @142vip/nest-typeorm / MongoEntityManager

类: MongoEntityManager

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:23

Entity manager supposed to work with any entity, automatically find its repository and call its methods, whatever entity type are you passing.

This implementation is used for MongoDB driver which has some specifics in its EntityManager.

theme_extends

构造函数

构造函数

new MongoEntityManager(connection): MongoEntityManager

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:26

参数

connection

DataSource

返回

MongoEntityManager

重写了

EntityManager.constructor

属性

@instanceof

readonly @instanceof: symbol

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:24

重写了

EntityManager.@instanceof


connection

readonly connection: DataSource

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:35

Connection used by this entity manager.

继承自

EntityManager.connection


plainObjectToEntityTransformer

protected plainObjectToEntityTransformer: PlainObjectToNewEntityTransformer

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:53

Plain to object transformer used in create and merge operations.

继承自

EntityManager.plainObjectToEntityTransformer


queryRunner?

readonly optional queryRunner?: QueryRunner

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:40

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

继承自

EntityManager.queryRunner


repositories

protected repositories: Map<EntityTarget<any>, Repository<any>>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:45

Once created and then reused by repositories. Created as a future replacement for the #repositories to provide a bit more perf optimization.

继承自

EntityManager.repositories


treeRepositories

protected treeRepositories: TreeRepository<any>[]

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:49

Once created and then reused by repositories.

继承自

EntityManager.treeRepositories

访问器

mongoQueryRunner

Getter 签名

get mongoQueryRunner(): MongoQueryRunner

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:25

返回

MongoQueryRunner

方法

aggregate()

aggregate<Entity, R>(entityClassOrName, pipeline, options?): AggregationCursor<R>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:107

Execute an aggregation framework pipeline against the collection.

类型参数

Entity

Entity

R

R = any

参数

entityClassOrName

EntityTarget<Entity>

pipeline

Document[]

options?

AggregateOptions

返回

AggregationCursor<R>


aggregateEntity()

aggregateEntity<Entity>(entityClassOrName, pipeline, options?): AggregationCursor<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:112

Execute an aggregation framework pipeline against the collection. This returns modified version of cursor that transforms each result into Entity model.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

pipeline

Document[]

options?

AggregateOptions

返回

AggregationCursor<Entity>


applyEntityTransformationToCursor()

protected applyEntityTransformationToCursor<Entity>(metadata, cursor): void

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:251

Overrides cursor's toArray and next methods to convert results to entity automatically.

类型参数

Entity

Entity extends ObjectLiteral

参数

metadata

EntityMetadata

cursor

FindCursor<Entity> | AggregationCursor<Entity>

返回

void


average()

average<Entity>(entityClass, columnName, where?): Promise<number | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:288

Return the AVG of a column

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

columnName

PickKeysByType<Entity, number>

where?

FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]

返回

Promise<number | null>

继承自

EntityManager.average


bulkWrite()

bulkWrite<Entity>(entityClassOrName, operations, options?): Promise<BulkWriteResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:116

Perform a bulkWrite operation without a fluent API.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

operations

AnyBulkWriteOperation<Document>[]

options?

BulkWriteOptions

返回

Promise<BulkWriteResult>


clear()

clear<Entity>(entityClass): Promise<void>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:366

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.

类型参数

Entity

Entity

参数

entityClass

EntityTarget<Entity>

返回

Promise<void>

参阅

https://stackoverflow.com/a/5972738/925151

继承自

EntityManager.clear


collectionIndexes()

collectionIndexes<Entity>(entityClassOrName): Promise<Document>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:174

Retrieve all the indexes on the collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

返回

Promise<Document>


collectionIndexExists()

collectionIndexExists<Entity>(entityClassOrName, indexes): Promise<boolean>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:178

Retrieve all the indexes on the collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

indexes

string | string[]

返回

Promise<boolean>


collectionIndexInformation()

collectionIndexInformation<Entity>(entityClassOrName, options?): Promise<any>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:182

Retrieves this collections index info.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options?

IndexInformationOptions

返回

Promise<any>


convertFindManyOptionsOrConditionsToMongodbQuery()

protected convertFindManyOptionsOrConditionsToMongodbQuery<Entity>(optionsOrConditions): ObjectLiteral | undefined

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:231

Converts FindManyOptions to mongodb query.

类型参数

Entity

Entity

参数

optionsOrConditions

any[] | MongoFindManyOptions<Entity> | Partial<Entity> | FilterOperators<Entity> | undefined

返回

ObjectLiteral | undefined


convertFindOneOptionsOrConditionsToMongodbQuery()

protected convertFindOneOptionsOrConditionsToMongodbQuery<Entity>(optionsOrConditions): ObjectLiteral | undefined

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:235

Converts FindOneOptions to mongodb query.

类型参数

Entity

Entity

参数

optionsOrConditions

MongoFindOneOptions<Entity> | Partial<Entity> | undefined

返回

ObjectLiteral | undefined


convertFindOptionsOrderToOrderCriteria()

protected convertFindOptionsOrderToOrderCriteria(order): ObjectLiteral

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:239

Converts FindOptions into mongodb order by criteria.

参数

order

ObjectLiteral

返回

ObjectLiteral


convertFindOptionsSelectToProjectCriteria()

protected convertFindOptionsSelectToProjectCriteria(selects): any

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:243

Converts FindOptions into mongodb select by criteria.

参数

selects

FindOptionsSelect<any> | FindOptionsSelectByString<any>

返回

any


convertMixedCriteria()

protected convertMixedCriteria(metadata, idMap): ObjectLiteral

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:247

Ensures given id is an id for query.

参数

metadata

EntityMetadata

idMap

any

返回

ObjectLiteral


count()

count<Entity>(entityClassOrName, query?, options?): Promise<number>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:120

Count number of matching documents in the db to a query.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query?

Filter<Document>

options?

CountOptions

返回

Promise<number>

重写了

EntityManager.count


countBy()

countBy<Entity>(entityClassOrName, query?, options?): Promise<number>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:128

Count number of matching documents in the db to a query.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query?

ObjectLiteral

options?

CountOptions

返回

Promise<number>

重写了

EntityManager.countBy


countDocuments()

countDocuments<Entity>(entityClassOrName, query?, options?): Promise<number>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:124

Count number of matching documents in the db to a query.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query?

Filter<Document>

options?

CountDocumentsOptions

返回

Promise<number>


create()

调用签名

create<Entity, EntityLike>(entityClass, plainObject?): Entity

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:107

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.

类型参数
Entity

Entity

EntityLike

EntityLike

参数
entityClass

EntityTarget<Entity>

plainObject?

EntityLike

返回

Entity

继承自

EntityManager.create

调用签名

create<Entity, EntityLike>(entityClass, plainObjects?): Entity[]

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:112

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

类型参数
Entity

Entity

EntityLike

EntityLike

参数
entityClass

EntityTarget<Entity>

plainObjects?

EntityLike[]

返回

Entity[]

继承自

EntityManager.create


createCollectionIndex()

createCollectionIndex<Entity>(entityClassOrName, fieldOrSpec, options?): Promise<string>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:132

Creates an index on the db and collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

fieldOrSpec

IndexSpecification

options?

CreateIndexesOptions

返回

Promise<string>


createCollectionIndexes()

createCollectionIndexes<Entity>(entityClassOrName, indexSpecs): Promise<string[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:138

Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

indexSpecs

IndexDescription[]

返回

Promise<string[]>


createCursor()

createCursor<Entity, T>(entityClassOrName, query?): FindCursor<T>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:98

Creates a cursor for a query that can be used to iterate over results from MongoDB.

类型参数

Entity

Entity

T

T = any

参数

entityClassOrName

EntityTarget<Entity>

query?

ObjectLiteral

返回

FindCursor<T>


createEntityCursor()

createEntityCursor<Entity>(entityClassOrName, query?): FindCursor<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:103

Creates a cursor for a query that can be used to iterate over results from MongoDB. This returns modified version of cursor that transforms each result into Entity model.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query?

ObjectLiteral

返回

FindCursor<Entity>


createQueryBuilder()

调用签名

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:82

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

类型参数
Entity

Entity extends ObjectLiteral

参数
entityClass

EntityTarget<Entity>

alias

string

queryRunner?

QueryRunner

返回

SelectQueryBuilder<Entity>

继承自

EntityManager.createQueryBuilder

调用签名

createQueryBuilder(queryRunner?): SelectQueryBuilder<any>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:86

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

参数
queryRunner?

QueryRunner

返回

SelectQueryBuilder<any>

继承自

EntityManager.createQueryBuilder


decrement()

decrement<Entity>(entityClass, conditions, propertyPath, value): Promise<UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:374

Decrements some column by provided value of the entities matched given conditions.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

conditions

any

propertyPath

string

value

string | number

返回

Promise<UpdateResult>

继承自

EntityManager.decrement


delete()

delete<Entity>(target, criteria): Promise<DeleteResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:94

Deletes entities by a given conditions. 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.

类型参数

Entity

Entity

参数

target

EntityTarget<Entity>

criteria

string | number | string[] | Date | ObjectId | ObjectLiteral[] | number[] | Date[] | ObjectId[]

返回

Promise<DeleteResult>

重写了

EntityManager.delete


deleteAll()

deleteAll<Entity>(targetOrEntity): Promise<DeleteResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:246

Deletes all entities of target type. This is a primitive operation without cascades, relations or other operations included. Executes fast and efficient DELETE query without WHERE clause.

WARNING! This method deletes ALL rows in the target table.

类型参数

Entity

Entity extends ObjectLiteral

参数

targetOrEntity

EntityTarget<Entity>

返回

Promise<DeleteResult>

继承自

EntityManager.deleteAll


deleteMany()

deleteMany<Entity>(entityClassOrName, query, options?): Promise<DeleteResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:142

Delete multiple documents on MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

options?

DeleteOptions

返回

Promise<DeleteResult>


deleteOne()

deleteOne<Entity>(entityClassOrName, query, options?): Promise<DeleteResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:146

Delete a document on MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

options?

DeleteOptions

返回

Promise<DeleteResult>


distinct()

distinct<Entity>(entityClassOrName, key, query, options?): Promise<any>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:150

The distinct command returns returns a list of distinct values for the given key across a collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

key

string

query

Filter<Document>

options?

CommandOperationOptions

返回

Promise<any>


dropCollectionIndex()

dropCollectionIndex<Entity>(entityClassOrName, indexName, options?): Promise<any>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:154

Drops an index from this collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

indexName

string

options?

CommandOperationOptions

返回

Promise<any>


dropCollectionIndexes()

dropCollectionIndexes<Entity>(entityClassOrName): Promise<any>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:158

Drops all indexes from the collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

返回

Promise<any>


executeFind()

protected executeFind<Entity>(entityClassOrName, optionsOrConditions?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:257

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

optionsOrConditions?

any[] | MongoFindManyOptions<Entity> | Partial<Entity>

返回

Promise<Entity[]>


executeFindAndCount()

executeFindAndCount<Entity>(entityClassOrName, optionsOrConditions?): Promise<[Entity[], number]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:261

Finds entities that match given find options or conditions.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

optionsOrConditions?

MongoFindManyOptions<Entity> | Partial<Entity>

返回

Promise<[Entity[], number]>


executeFindOne()

protected executeFindOne<Entity>(entityClassOrName, optionsOrConditions?, maybeOptions?): Promise<Entity | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:256

Finds first entity that matches given conditions and/or find options.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

optionsOrConditions?

any

maybeOptions?

MongoFindOneOptions<Entity>

返回

Promise<Entity | null>


exists()

exists<Entity>(entityClass, options?): Promise<boolean>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:266

Checks whether any entity exists with the given options.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

options?

FindManyOptions<Entity>

返回

Promise<boolean>

继承自

EntityManager.exists


existsBy()

existsBy<Entity>(entityClass, where): Promise<boolean>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:270

Checks whether any entity exists with the given conditions.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

where

FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]

返回

Promise<boolean>

继承自

EntityManager.existsBy


filterSoftDeleted()

protected filterSoftDeleted<Entity>(cursor, deleteDateColumn, query?): void

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:252

类型参数

Entity

Entity

参数

cursor

FindCursor<Entity>

deleteDateColumn

ColumnMetadata

query?

ObjectLiteral

返回

void


find()

find<Entity>(entityClassOrName, optionsOrConditions?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:33

Finds entities that match given find options or conditions.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

optionsOrConditions?

FindManyOptions<Entity> | Partial<Entity> | FilterOperators<Entity>

返回

Promise<Entity[]>

重写了

EntityManager.find


findAndCount()

findAndCount<Entity>(entityClassOrName, options?): Promise<[Entity[], number]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:39

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

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options?

MongoFindManyOptions<Entity>

返回

Promise<[Entity[], number]>

重写了

EntityManager.findAndCount


findAndCountBy()

findAndCountBy<Entity>(entityClassOrName, where): Promise<[Entity[], number]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:43

Finds entities that match given where conditions.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

where

any

返回

Promise<[Entity[], number]>

重写了

EntityManager.findAndCountBy


findBy()

findBy<Entity>(entityClassOrName, where): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:47

Finds entities that match given WHERE conditions.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

where

any

返回

Promise<Entity[]>

重写了

EntityManager.findBy


findByIds()

findByIds<Entity>(entityClassOrName, ids, optionsOrConditions?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:54

Finds entities by ids. Optionally find options can be applied.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

ids

any[]

optionsOrConditions?

FindManyOptions<Entity> | Partial<Entity>

返回

Promise<Entity[]>

已被弃用

use findBy method instead.

重写了

EntityManager.findByIds


findOne()

findOne<Entity>(entityClassOrName, options): Promise<Entity | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:58

Finds first entity that matches given conditions and/or find options.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options

MongoFindOneOptions<Entity>

返回

Promise<Entity | null>

重写了

EntityManager.findOne


findOneAndDelete()

findOneAndDelete<Entity>(entityClassOrName, query, options?): Promise<Document | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:162

Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

ObjectLiteral

options?

FindOneAndDeleteOptions

返回

Promise<Document | null>


findOneAndReplace()

findOneAndReplace<Entity>(entityClassOrName, query, replacement, options?): Promise<Document | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:166

Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

replacement

Document

options?

FindOneAndReplaceOptions

返回

Promise<Document | null>


findOneAndUpdate()

findOneAndUpdate<Entity>(entityClassOrName, query, update, options?): Promise<Document | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:170

Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

update

UpdateFilter<Document>

options?

FindOneAndUpdateOptions

返回

Promise<Document | null>


findOneBy()

findOneBy<Entity>(entityClassOrName, where): Promise<Entity | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:62

Finds first entity that matches given WHERE conditions.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

where

any

返回

Promise<Entity | null>

重写了

EntityManager.findOneBy


findOneById()

findOneById<Entity>(entityClassOrName, id): Promise<Entity | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:72

Finds entity that matches given id.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

id

string | number | Date | ObjectId

返回

Promise<Entity | null>

已被弃用

use findOneBy method instead in conjunction with In operator, for example:

.findOneBy({ id: 1 // where "id" is your primary column name })

重写了

EntityManager.findOneById


findOneByOrFail()

findOneByOrFail<Entity>(entityClass, where): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:359

Finds first entity that matches given where condition. If entity was not found in the database - rejects with error.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

where

FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]

返回

Promise<Entity>

继承自

EntityManager.findOneByOrFail


findOneOrFail()

findOneOrFail<Entity>(entityClass, options): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:354

Finds first entity by a given find options. If entity was not found in the database - rejects with error.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

options

FindOneOptions<Entity>

返回

Promise<Entity>

继承自

EntityManager.findOneOrFail


getCustomRepository()

getCustomRepository<T>(customRepository): T

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:404

Gets custom entity repository marked with

类型参数

T

T

参数

customRepository

ObjectType<T>

返回

T

Entity Repository

decorator.

已被弃用

use Repository.extend to create custom repositories

继承自

EntityManager.getCustomRepository


getId()

调用签名

getId(entity): any

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:98

Gets entity mixed id.

参数
entity

any

返回

any

继承自

EntityManager.getId

调用签名

getId(target, entity): any

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:102

Gets entity mixed id.

参数
target

EntityTarget<any>

entity

any

返回

any

继承自

EntityManager.getId


getMongoRepository()

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:392

Gets mongodb repository for the given entity class.

类型参数

Entity

Entity extends ObjectLiteral

参数

target

EntityTarget<Entity>

返回

MongoRepository<Entity>

继承自

EntityManager.getMongoRepository


getRepository()

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:381

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.

类型参数

Entity

Entity extends ObjectLiteral

参数

target

EntityTarget<Entity>

返回

Repository<Entity>

继承自

EntityManager.getRepository


getTreeRepository()

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:388

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.

类型参数

Entity

Entity extends ObjectLiteral

参数

target

EntityTarget<Entity>

返回

TreeRepository<Entity>

继承自

EntityManager.getTreeRepository


hasId()

调用签名

hasId(entity): boolean

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:90

Checks if entity has an id.

参数
entity

any

返回

boolean

继承自

EntityManager.hasId

调用签名

hasId(target, entity): boolean

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:94

Checks if entity of given schema name has an id.

参数
target

string | Function

entity

any

返回

boolean

继承自

EntityManager.hasId


increment()

increment<Entity>(entityClass, conditions, propertyPath, value): Promise<UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:370

Increments some column by provided value of the entities matched given conditions.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

conditions

any

propertyPath

string

value

string | number

返回

Promise<UpdateResult>

继承自

EntityManager.increment


initializeOrderedBulkOp()

initializeOrderedBulkOp<Entity>(entityClassOrName, options?): OrderedBulkOperation

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:186

Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options?

BulkWriteOptions

返回

OrderedBulkOperation


initializeUnorderedBulkOp()

initializeUnorderedBulkOp<Entity>(entityClassOrName, options?): UnorderedBulkOperation

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:190

Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options?

BulkWriteOptions

返回

UnorderedBulkOperation


insert()

insert<Entity>(target, entity): Promise<InsertResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:80

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.

类型参数

Entity

Entity

参数

target

EntityTarget<Entity>

entity

_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity> | _QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity>[]

返回

Promise<InsertResult>

重写了

EntityManager.insert


insertMany()

insertMany<Entity>(entityClassOrName, docs, options?): Promise<InsertManyResult<Document>>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:194

Inserts an array of documents into MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

docs

OptionalId<Document>[]

options?

BulkWriteOptions

返回

Promise<InsertManyResult<Document>>


insertOne()

insertOne<Entity>(entityClassOrName, doc, options?): Promise<InsertOneResult<Document>>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:198

Inserts a single document into MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

doc

OptionalId<Document>

options?

InsertOneOptions

返回

Promise<InsertOneResult<Document>>


isCapped()

isCapped<Entity>(entityClassOrName): Promise<any>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:202

Returns if the collection is a capped collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

返回

Promise<any>


listCollectionIndexes()

listCollectionIndexes<Entity>(entityClassOrName, options?): ListIndexesCursor

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:206

Get the list of all indexes information for the collection.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options?

ListIndexesOptions

返回

ListIndexesCursor


maximum()

maximum<Entity>(entityClass, columnName, where?): Promise<number | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:296

Return the MAX of a column

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

columnName

PickKeysByType<Entity, number>

where?

FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]

返回

Promise<number | null>

继承自

EntityManager.maximum


merge()

merge<Entity>(entityClass, mergeIntoEntity, ...entityLikes): Entity

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:116

Merges two entities into one new entity.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

mergeIntoEntity

Entity

entityLikes

...DeepPartial<Entity>[]

返回

Entity

继承自

EntityManager.merge


minimum()

minimum<Entity>(entityClass, columnName, where?): Promise<number | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:292

Return the MIN of a column

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

columnName

PickKeysByType<Entity, number>

where?

FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]

返回

Promise<number | null>

继承自

EntityManager.minimum


preload()

preload<Entity>(entityClass, entityLike): Promise<Entity | undefined>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:123

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.

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

entityLike

DeepPartial<Entity>

返回

Promise<Entity | undefined>

继承自

EntityManager.preload


query()

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:70

Executes raw SQL query and returns raw database results.

类型参数

T

T = any

参数

query

string

parameters?

any[]

返回

Promise<T>

参阅

Official docs for examples.

继承自

EntityManager.query


recover()

调用签名

recover<Entity>(entities, options?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:193

Recovers all given entities.

类型参数
Entity

Entity

参数
entities

Entity[]

options?

SaveOptions

返回

Promise<Entity[]>

继承自

EntityManager.recover

调用签名

recover<Entity>(entity, options?): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:197

Recovers a given entity.

类型参数
Entity

Entity

参数
entity

Entity

options?

SaveOptions

返回

Promise<Entity>

继承自

EntityManager.recover

调用签名

recover<Entity, T>(targetOrEntity, entities, options?): Promise<T[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:201

Recovers all given entities.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entities

T[]

options?

SaveOptions

返回

Promise<T[]>

继承自

EntityManager.recover

调用签名

recover<Entity, T>(targetOrEntity, entity, options?): Promise<T>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:205

Recovers a given entity.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entity

T

options?

SaveOptions

返回

Promise<T>

继承自

EntityManager.recover


release()

release(): Promise<void>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:410

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.

返回

Promise<void>

继承自

EntityManager.release


remove()

调用签名

remove<Entity>(entity, options?): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:161

Removes a given entity from the database.

类型参数
Entity

Entity

参数
entity

Entity

options?

RemoveOptions

返回

Promise<Entity>

继承自

EntityManager.remove

调用签名

remove<Entity>(targetOrEntity, entity, options?): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:165

Removes a given entity from the database.

类型参数
Entity

Entity

参数
targetOrEntity

EntityTarget<Entity>

entity

Entity

options?

RemoveOptions

返回

Promise<Entity>

继承自

EntityManager.remove

调用签名

remove<Entity>(entity, options?): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:169

Removes a given entity from the database.

类型参数
Entity

Entity

参数
entity

Entity[]

options?

RemoveOptions

返回

Promise<Entity>

继承自

EntityManager.remove

调用签名

remove<Entity>(targetOrEntity, entity, options?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:173

Removes a given entity from the database.

类型参数
Entity

Entity

参数
targetOrEntity

EntityTarget<Entity>

entity

Entity[]

options?

RemoveOptions

返回

Promise<Entity[]>

继承自

EntityManager.remove


rename()

rename<Entity>(entityClassOrName, newName, options?): Promise<Collection<Document>>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:210

Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

newName

string

options?

RenameOptions

返回

Promise<Collection<Document>>


replaceOne()

replaceOne<Entity>(entityClassOrName, query, doc, options?): Promise<Document | UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:214

Replace a document on MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

doc

Document

options?

ReplaceOptions

返回

Promise<Document | UpdateResult>


restore()

restore<Entity>(targetOrEntity, criteria): Promise<UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:262

Restores entities 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.

类型参数

Entity

Entity extends ObjectLiteral

参数

targetOrEntity

EntityTarget<Entity>

criteria

any

返回

Promise<UpdateResult>

继承自

EntityManager.restore


save()

调用签名

save<Entity>(entities, options?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:128

Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.

类型参数
Entity

Entity

参数
entities

Entity[]

options?

SaveOptions

返回

Promise<Entity[]>

继承自

EntityManager.save

调用签名

save<Entity>(entity, options?): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:133

Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.

类型参数
Entity

Entity

参数
entity

Entity

options?

SaveOptions

返回

Promise<Entity>

继承自

EntityManager.save

调用签名

save<Entity, T>(targetOrEntity, entities, options): Promise<T[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:138

Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entities

T[]

options

SaveOptions & object

返回

Promise<T[]>

继承自

EntityManager.save

调用签名

save<Entity, T>(targetOrEntity, entities, options?): Promise<T & Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:145

Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entities

T[]

options?

SaveOptions

返回

Promise<T & Entity[]>

继承自

EntityManager.save

调用签名

save<Entity, T>(targetOrEntity, entity, options): Promise<T>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:150

Saves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entity

T

options

SaveOptions & object

返回

Promise<T>

继承自

EntityManager.save

调用签名

save<Entity, T>(targetOrEntity, entity, options?): Promise<T & Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:157

Saves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entity

T

options?

SaveOptions

返回

Promise<T & Entity>

继承自

EntityManager.save


softDelete()

softDelete<Entity>(targetOrEntity, criteria): Promise<UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:254

Records 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 UPDATE query. Does not check if entity exist in the database. Condition(s) cannot be empty.

类型参数

Entity

Entity extends ObjectLiteral

参数

targetOrEntity

EntityTarget<Entity>

criteria

any

返回

Promise<UpdateResult>

继承自

EntityManager.softDelete


softRemove()

调用签名

softRemove<Entity>(entities, options?): Promise<Entity[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:177

Records the delete date of all given entities.

类型参数
Entity

Entity

参数
entities

Entity[]

options?

SaveOptions

返回

Promise<Entity[]>

继承自

EntityManager.softRemove

调用签名

softRemove<Entity>(entity, options?): Promise<Entity>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:181

Records the delete date of a given entity.

类型参数
Entity

Entity

参数
entity

Entity

options?

SaveOptions

返回

Promise<Entity>

继承自

EntityManager.softRemove

调用签名

softRemove<Entity, T>(targetOrEntity, entities, options?): Promise<T[]>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:185

Records the delete date of all given entities.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entities

T[]

options?

SaveOptions

返回

Promise<T[]>

继承自

EntityManager.softRemove

调用签名

softRemove<Entity, T>(targetOrEntity, entity, options?): Promise<T>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:189

Records the delete date of a given entity.

类型参数
Entity

Entity

T

T

参数
targetOrEntity

EntityTarget<Entity>

entity

T

options?

SaveOptions

返回

Promise<T>

继承自

EntityManager.softRemove


sql()

sql<T>(strings, ...values): Promise<T>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:78

Tagged template function that executes raw SQL query and returns raw database results. Template expressions are automatically transformed into database parameters. Raw query execution is supported only by relational databases (MongoDB is not supported). Note: Don't call this as a regular function, it is meant to be used with backticks to tag a template literal. Example: entityManager.sqlSELECT * FROM table_name WHERE id = ${id}

类型参数

T

T = any

参数

strings

TemplateStringsArray

values

...unknown[]

返回

Promise<T>

继承自

EntityManager.sql


stats()

stats<Entity>(entityClassOrName, options?): Promise<CollStats>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:218

Get all the collection statistics.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

options?

CollStatsOptions

返回

Promise<CollStats>


sum()

sum<Entity>(entityClass, columnName, where?): Promise<number | null>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:284

Return the SUM of a column

类型参数

Entity

Entity extends ObjectLiteral

参数

entityClass

EntityTarget<Entity>

columnName

PickKeysByType<Entity, number>

where?

FindOptionsWhere<Entity> | FindOptionsWhere<Entity>[]

返回

Promise<number | null>

继承自

EntityManager.sum


transaction()

调用签名

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:59

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

类型参数
T

T

参数
runInTransaction

(entityManager) => Promise<T>

返回

Promise<T>

继承自

EntityManager.transaction

调用签名

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

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:64

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

类型参数
T

T

参数
isolationLevel

IsolationLevel

runInTransaction

(entityManager) => Promise<T>

返回

Promise<T>

继承自

EntityManager.transaction


update()

update<Entity>(target, criteria, partialEntity): Promise<UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:87

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.

类型参数

Entity

Entity

参数

target

EntityTarget<Entity>

criteria

string | number | string[] | ObjectLiteral | Date | ObjectId | number[] | Date[] | ObjectId[]

partialEntity

QueryDeepPartialEntity<Entity>

返回

Promise<UpdateResult>

重写了

EntityManager.update


updateAll()

updateAll<Entity>(target, partialEntity, options?): Promise<UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:230

Updates all entities of target type, setting fields from supplied partial entity. This is a primitive operation without cascades, relations or other operations included. Executes fast and efficient UPDATE query without WHERE clause.

WARNING! This method updates ALL rows in the target table.

类型参数

Entity

Entity extends ObjectLiteral

参数

target

EntityTarget<Entity>

partialEntity

QueryDeepPartialEntity<Entity>

options?

RepositoryUpdateOptions

返回

Promise<UpdateResult>

继承自

EntityManager.updateAll


updateMany()

updateMany<Entity>(entityClassOrName, query, update, options?): Promise<Document | UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:223

Update multiple documents on MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

update

UpdateFilter<Document>

options?

UpdateOptions

返回

Promise<Document | UpdateResult>


updateOne()

updateOne<Entity>(entityClassOrName, query, update, options?): Promise<Document | UpdateResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:227

Update a single document on MongoDB.

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

query

Filter<Document>

update

UpdateFilter<Document>

options?

UpdateOptions

返回

Promise<Document | UpdateResult>


upsert()

upsert<Entity>(target, entityOrEntities, conflictPathsOrOptions): Promise<InsertResult>

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:214

类型参数

Entity

Entity extends ObjectLiteral

参数

target

EntityTarget<Entity>

entityOrEntities

_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity> | _QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity>[]

conflictPathsOrOptions

string[] | UpsertOptions<Entity>

返回

Promise<InsertResult>

继承自

EntityManager.upsert


watch()

watch<Entity>(entityClassOrName, pipeline?, options?): ChangeStream

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/MongoEntityManager.d.ts:219

类型参数

Entity

Entity

参数

entityClassOrName

EntityTarget<Entity>

pipeline?

Document[]

options?

ChangeStreamOptions

返回

ChangeStream


withRepository()

withRepository<Entity, R>(repository): R

定义于: node_modules/.pnpm/typeorm@0.3.30_ioredis@5.6.0_mongodb@6.19.0_mssql@11.0.1_mysql2@3.15.1_pg@8.11.3_ts-node@10.9_6zvdq3z7xgsf663jy3j6oymho4/node_modules/typeorm/entity-manager/EntityManager.d.ts:398

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

Entity extends ObjectLiteral

R

R extends Repository<any>

参数

repository

R & Repository<Entity>

返回

R

继承自

EntityManager.withRepository

Clone this wiki locally