Repository: typeorm/typeorm
File: src/entity-manager/EntityManager.ts (TypeScript)

Code before:

        if (
            typeof criteria === "string" ||
            typeof criteria === "number" ||
            criteria instanceof Date ||
            Array.isArray(criteria)
        ) {
            return this.createQueryBuilder()
                .restore()
                .from(targetOrEntity)
                .whereInIds(criteria)
                .execute()
        } else {
            return this.createQueryBuilder()
                .restore()
                .from(targetOrEntity)
                .where(criteria)
                .execute()
        }
    }

    /**
     * Checks whether any entity exists with the given condition
     */
    exists<Entity>(
        entityClass: EntityTarget<Entity>,
        options?: FindManyOptions<Entity>,
    ): Promise<boolean> {
        const metadata = this.connection.getMetadata(entityClass)
        return this.createQueryBuilder(
            entityClass,
            FindOptionsUtils.extractFindManyOptionsAlias(options) ||
                metadata.name,
        )
            .setFindOptions(options || {})
            .getExists()
    }

    /**
     * Counts entities that match given options.
     * Useful for pagination.
     */
    count<Entity>(
        entityClass: EntityTarget<Entity>,
        options?: FindManyOptions<Entity>,
    ): Promise<number> {
        const metadata = this.connection.getMetadata(entityClass)
        return this.createQueryBuilder(
            entityClass,
            FindOptionsUtils.extractFindManyOptionsAlias(options) ||
                metadata.name,

Review comment (suggestion):
please also add tests checking this function and testing different `options?: FindManyOptions<Entity>`

Code after:
        }

        if (
            typeof criteria === "string" ||
            typeof criteria === "number" ||
            criteria instanceof Date ||
            Array.isArray(criteria)
        ) {
            return this.createQueryBuilder()
                .restore()
                .from(targetOrEntity)
                .whereInIds(criteria)
                .execute()
        } else {
            return this.createQueryBuilder()
                .restore()
                .from(targetOrEntity)
                .where(criteria)
                .execute()
        }
    }

    /**
     * Checks whether any entity exists with the given condition
     */
    exists<Entity>(
        entityClass: EntityTarget<Entity>,
        options?: FindManyOptions<Entity>,
    ): Promise<boolean> {
        const metadata = this.connection.getMetadata(entityClass)
        return this.createQueryBuilder(
            entityClass,
            FindOptionsUtils.extractFindManyOptionsAlias(options) ||
                metadata.name,
        )
            .setFindOptions(options || {})
            .getExists()
    }

    /**
     * Counts entities that match given options.
     * Useful for pagination.
     */
    count<Entity extends ObjectLiteral>(
        entityClass: EntityTarget<Entity>,
        options?: FindManyOptions<Entity>,
    ): Promise<number> {
        const metadata = this.connection.getMetadata(entityClass)
        return this.createQueryBuilder(
            entityClass,
            FindOptionsUtils.extractFindManyOptionsAlias(options) ||