Repository: typeorm/typeorm
File: src/query-builder/SelectQueryBuilder.ts (TypeScript)

Code before:
                    )
                    if (condition) andConditions.push(condition)
                } else if (relation) {
                    // if all properties of where are undefined we don't need to join anything
                    // this can happen when user defines map with conditional queries inside
                    if (typeof where[key] === "object") {
                        const allAllUndefined = Object.keys(where[key]).every(
                            (k) => where[key][k] === undefined,
                        )
                        if (allAllUndefined) {
                            continue
                        }
                    }

                    if (InstanceChecker.isFindOperator(where[key])) {
                        if (
                            [
                                "moreThan",
                                "lessThan",
                                "moreThanOrEqual",
                                "lessThanOrEqual",
                            ].includes(where[key].type)
                        ) {
                            const sqlOperator =
                                (where[key].type.startsWith("moreThan")
                                    ? ">"
                                    : "<") +
                                (where[key].type.endsWith("OrEqual") ? "=" : "")
                            // basically relation count functionality
                            const qb: QueryBuilder<any> = this.subQuery()
                            if (relation.isManyToManyOwner) {
                                qb.select("COUNT(*)")
                                    .from(
                                        relation.joinTableName,
                                        relation.joinTableName,
                                    )
                                    .where(
                                        relation.joinColumns
                                            .map((column) => {
                                                return `${
                                                    relation.joinTableName
                                                }.${
                                                    column.propertyName
                                                } = ${alias}.${
                                                    column.referencedColumn!
                                                        .propertyName
                                                }`
                                            })
                                            .join(" AND "),
                                    )
                            } else if (relation.isManyToManyNotOwner) {

Review comment (suggestion):
code works, however I would prefer a simpler code. simple if-elseif statements work better for the code understanding. 

Code after:
                    )
                    if (condition) andConditions.push(condition)
                } else if (relation) {
                    // if all properties of where are undefined we don't need to join anything
                    // this can happen when user defines map with conditional queries inside
                    if (typeof where[key] === "object") {
                        const allAllUndefined = Object.keys(where[key]).every(
                            (k) => where[key][k] === undefined,
                        )
                        if (allAllUndefined) {
                            continue
                        }
                    }

                    if (InstanceChecker.isFindOperator(where[key])) {
                        if (
                            where[key].type === "moreThan" ||
                            where[key].type === "lessThan" ||
                            where[key].type === "moreThanOrEqual" ||
                            where[key].type === "lessThanOrEqual"
                        ) {
                            let sqlOperator = ""
                            if (where[key].type === "moreThan") {
                                sqlOperator = ">"
                            } else if (where[key].type === "lessThan") {
                                sqlOperator = "<"
                            } else if (where[key].type === "moreThanOrEqual") {
                                sqlOperator = ">="
                            } else if (where[key].type === "lessThanOrEqual") {
                                sqlOperator = "<="
                            }
                            // basically relation count functionality
                            const qb: QueryBuilder<any> = this.subQuery()
                            if (relation.isManyToManyOwner) {
                                qb.select("COUNT(*)")
                                    .from(
                                        relation.joinTableName,
                                        relation.joinTableName,
                                    )
                                    .where(
                                        relation.joinColumns
                                            .map((column) => {
                                                return `${
                                                    relation.joinTableName
                                                }.${
                                                    column.propertyName
                                                } = ${alias}.${
                                                    column.referencedColumn!
                                                        .propertyName
                                                }`
                                            })