Roy
10/06/2020, 9:28 AMasync createPointsObject(
points: number,
notification: Notification,
userEmail: string
) {
return await this.prismaService.client.points.create({
data: {
points,
Notification: { connect: { id: Notification.id } },
},
});
}
Here is my schema.
model Points {
id String @id @default(cuid())
points Int
createdAt DateTime @default(now())
Notification Notification
}
model Notification {
id String @id @default(uuid())
points Points @relation(fields: [pointsId], references: [id])
pointsId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Full Error log:
[dev ] The change you are trying to make would violate the required relation 'NotificationToPoints' between the `Notification` and `Points` models.
.....................................................
[dev ] code: 'P2014',
[dev ] meta: {
[dev ] relation_name: 'NotificationToPoints',
[dev ] model_a_name: 'Notification',
[dev ] model_b_name: 'Points'
[dev ] }
[dev ] }
Ryan
10/06/2020, 9:40 AMmodel Points {
id String @id @default(cuid())
points Int
createdAt DateTime @default(now())
Notification Notification
}
model Notification {
id String @id @default(uuid())
points Points? @relation(fields: [pointsId], references: [id])
pointsId String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}