fixed the issue in user address detail

This commit is contained in:
2026-02-11 15:04:09 +05:30
parent e154be70ad
commit 036f7ab130
2 changed files with 5 additions and 5 deletions

View File

@@ -306,7 +306,7 @@ model Cities {
id Int @id @default(autoincrement())
stateXid Int @map("state_xid")
states States @relation(fields: [stateXid], references: [id], onDelete: Cascade)
cityName String @map("city_name") @db.VarChar(50)
cityName String @unique @map("city_name") @db.VarChar(50)
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

View File

@@ -346,8 +346,8 @@ export class UserService {
}
// 2⃣ State: find or create (GLOBAL UNIQUE)
let state = await tx.states.findUnique({
where: { stateName },
let state = await tx.states.findFirst({
where: { stateName, countryXid: country.id },
select: { id: true },
});
@@ -362,8 +362,8 @@ export class UserService {
}
// 3⃣ City: find or create (GLOBAL UNIQUE)
let city = await tx.cities.findUnique({
where: { cityName },
let city = await tx.cities.findFirst({
where: { cityName, stateXid: state.id },
select: { id: true },
});