update: join the address to the real and legal user
This commit is contained in:
@@ -13,7 +13,7 @@ export function databaseConfigs(): TypeOrmModuleAsyncOptions {
|
||||
username: configService.getOrThrow<string>("DB_USER"),
|
||||
password: configService.getOrThrow<string>("DB_PASS"),
|
||||
autoLoadEntities: true,
|
||||
synchronize: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : true,
|
||||
synchronize: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : false,
|
||||
logging: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : true,
|
||||
migrationsTableName: "typeorm_migrations",
|
||||
migrationsRun: false,
|
||||
|
||||
@@ -92,9 +92,30 @@ export class UserRepository extends Repository<User> {
|
||||
.leftJoin("user.roles", "role")
|
||||
.where("role.name = :roleName", { roleName: RoleEnum.USER })
|
||||
.leftJoin("user.legalUser", "legalUser")
|
||||
.addSelect(["legalUser.id", "legalUser.registrationName"])
|
||||
.addSelect([
|
||||
"legalUser.id",
|
||||
"legalUser.registrationName",
|
||||
"legalUser.nationalIdentity",
|
||||
"legalUser.economicCode",
|
||||
"legalUser.registrationCode",
|
||||
])
|
||||
.leftJoinAndSelect("legalUser.address", "address")
|
||||
.leftJoinAndSelect("address.city", "city")
|
||||
.leftJoinAndSelect("city.province", "province")
|
||||
.leftJoin("user.realUser", "realUser")
|
||||
.addSelect(["realUser.id", "realUser.firstName", "realUser.lastName"])
|
||||
.addSelect([
|
||||
"realUser.id",
|
||||
"realUser.firstName",
|
||||
"realUser.lastName",
|
||||
"realUser.phone",
|
||||
"realUser.gender",
|
||||
"realUser.nationalCode",
|
||||
"realUser.birthDate",
|
||||
"realUser.nationality",
|
||||
])
|
||||
.leftJoinAndSelect("realUser.address", "realAddress")
|
||||
.leftJoinAndSelect("realAddress.city", "realCity")
|
||||
.leftJoinAndSelect("realCity.province", "realProvince")
|
||||
.loadRelationCountAndMap("user.invoicesCount", "user.invoices")
|
||||
.loadRelationCountAndMap("user.subscriptionsCount", "user.subscriptions")
|
||||
.loadRelationCountAndMap("user.ticketsCount", "user.tickets");
|
||||
|
||||
Reference in New Issue
Block a user