Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I new to goprisma and need some help with update #1395

Open
manh7890 opened this issue Oct 23, 2024 · 1 comment
Open

I new to goprisma and need some help with update #1395

manh7890 opened this issue Oct 23, 2024 · 1 comment

Comments

@manh7890
Copy link

manh7890 commented Oct 23, 2024

Hi i have an issue with update here my model

model querylog {
  id                    String    @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  table_names           String?
  start_timestamp       DateTime? @db.Timestamptz(6)
  query_duration        BigInt?
  status                String?
  total_matched_records BigInt?
  filter_conditions     String?
  description           String?
  query_creator_email   String
  created_date          DateTime? @default(now()) @db.Timestamptz(6)
  users                 users     @relation(fields: [query_creator_email], references: [email], onDelete: NoAction, onUpdate: NoAction, map: "fk_query_creator")
}

model task_manager_data {
  id                 String    @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  status             String?
  log_message        String?
  type_of_task       String?
  task_creator_email String
  input              String?
  create_date        DateTime? @default(now()) @db.Timestamptz(6)
  users              users     @relation(fields: [task_creator_email], references: [email], onDelete: NoAction, onUpdate: NoAction, map: "fk_task_creator")
}

model users {
  id                String              @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  email             String              @unique
  role              String?             @default("user") @db.VarChar(255)
  password_hash     String
  is_active         Boolean?            @default(true)
 
  querylog          querylog[]
  
  task_manager_data task_manager_data[]
}

i want to update email of user and all so update all the task_creator_email and query_creator_email to a new email to but i dont know where to start please help me if you know ho to do it thank

@steebchen
Copy link
Owner

You should try asking ChatGPT to help model your SQL schema and write it in Prisma schema. Maybe you want to remove the task_creator_email and instead use the user relation to the user to keep track of which user created a task_manager_data entry.

Then for actual Go code here is an example of updating records using fields or relations: https://goprisma.org/docs/walkthrough/update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants