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

One-To-One relations are translated to One-To-Many #8

Open
joergjaeckel opened this issue Sep 13, 2024 · 0 comments
Open

One-To-One relations are translated to One-To-Many #8

joergjaeckel opened this issue Sep 13, 2024 · 0 comments
Assignees

Comments

@joergjaeckel
Copy link

model interval {
  id              String         @id @default(uuid()) @db.Uuid
...
  organization_id String         @unique @db.Uuid
  organization    organization @relation(fields: [organization_id], references: [id])
}

model organization {
  id                   String           @id @default(uuid()) @db.Uuid
...
  interval interval?
}

will be

export const intervalRelations = relations(interval, ({ one }) => ({
	organization: one(organization, {
		relationName: 'intervalToorganization',
		fields: [interval.organization_id],
		references: [organization.id]
	})
}));

export const organizationRelations = relations(organization, ({ many }) => ({
	interval: many(interval, {
		relationName: 'intervalToorganization'
	})
}));

but should be ONE on both sides

@Sukairo-02 Sukairo-02 self-assigned this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants