Martin Pinnau
05/12/2022, 8:17 AMtype Email @db(name: "emails") {
id: ID! @id
name: String @unique
emailMessage: EmailMessage
emailSubject: EmailSubject
receiverGroup: [Receiver]
isActivated: Boolean! @default(value: true)
role: String
btnName: String
}
type EmailMessage @embedded {
id: ID! @id
messageDe: String
messageEn: String
}
type EmailSubject @embedded {
id: ID! @id
subjectDe: String
subjectEn: String
}
type Receiver @embedded {
id: ID! @id
email: String!
firstName: String
lastName: String
}
This is working perfectly fine with prisma1 (prisma-client-lib 1.34.5).
Due to restrictions by nexus-plugin-prisma I'm bound to prisma version 2.23.0 regarding upgrade.
With this version I can't use the model as it is, I have to add relation keys to all models (formerly types) listed.
Prisma1 seems to be able to handle this internally without secondary keys.
How can I achieve this with prisma2 and mongodb ?Joël
nexus-plugin-prisma
Here is the official upgrade Guide to migrate from the Prisma 1 MongoDB Beta to MongoDB on Prisma 3.12.0 and later.
https://www.prisma.io/docs/guides/upgrade-guides/upgrade-from-prisma-1/upgrade-from-mongodb-beta
Note that Preview support for Embedded documents were added in 3.10.0
And that the MongoDB connector went GA, Generally Available in 3.12.0
So using 3.12.0 or later seems like the best thing to doMartin Pinnau
05/12/2022, 8:43 AMMartin Pinnau
05/12/2022, 9:00 AMmodel EmailMessage @embedded {
id String @id @map("_id") @db.ObjectId
messageDe String
messageEn String
}
results in an error running generate
Error validating: This line is invalid. It does not start with any known Prisma schema keyword.
model EmailMessage @embedded {
...
model is a schema keyword, isn't it ?Martin Pinnau
05/12/2022, 9:45 AM@embedded
seems to be causing the problem