Peter
08/23/2022, 9:38 AMmodel Domain {
id String @id @default(cuid())
domain String @unique
majesticDomainData MajesticDomainData?
}
model MajesticDomainData {
id String @id @default(cuid())
domain Domain @relation(fields: [domainId], references: [id])
domainId String @unique
topics MajesticTopicalData[]
}
model MajesticTopicalTrustFlow {
id String @id @default(cuid())
topic String @unique
domainData MajesticTopicalData[]
}
model MajesticTopicalData {
domainData MajesticDomainData @relation(fields: [domainDataId], references: [id])
domainDataId String
topicalTrustFlow MajesticTopicalTrustFlow @relation(fields: [topicalTrustFlowId], references: [id])
topicalTrustFlowId String
topicalPercent Decimal @db.Decimal(5, 4)
@@id([domainDataId, topicalTrustFlowId])
}
prisma.domain.update({
where: {<http://asd.com|asd.com>},
data: {
majesticDomainData: {
create: {
topics: {
create: [
{
topic: 'health',
topicalPercent: 0.24
},
{
topic: 'rec',
topicalPercent: 0.33
},
]
},
}
}
},
})
+ topicalTrustFlow: {
+ create?: MajesticTopicalTrustFlowCreateWithoutDomainInput | MajesticTopicalTrustFlowUncheckedCreateWithoutDomainInput,
+ connectOrCreate?: MajesticTopicalTrustFlowCreateOrConnectWithoutDomainInput,
+ connect?: MajesticTopicalTrustFlowWhereUniqueInput
+ }
Im not sure if im connecting the many to many relationship correctly, its asking for my explicit tableGustavo
08/23/2022, 9:39 AMRaphael Etim
08/23/2022, 9:44 AMPeter
08/23/2022, 9:48 AMRaphael Etim
08/23/2022, 9:50 AMPeter
08/23/2022, 9:51 AMPeter
08/23/2022, 9:52 AMRaphael Etim
08/23/2022, 10:05 AMtopic
is not a property of MajesticTopicalData
. You should not have topic as part of the fields.Raphael Etim
08/23/2022, 10:08 AMtopicalTrustFlow
and topicalPercent
Peter
08/23/2022, 10:16 AMtopics: {
create: [
{
topicalPercent: 0.24,
topicalTrustFlow: {
create: {topic: 'asdfsd'}
}
},
// {
// topicalPercent: 0.44
// },
]
},
But get this error:
The change you are trying to make would violate the required relation 'DomainToMajesticDomainData' between the `Domain` and `MajesticDomainData` models.
code: 'P2014',
clientVersion: '4.1.1',
meta: {
relation_name: 'DomainToMajesticDomainData',
model_a_name: 'Domain',
model_b_name: 'MajesticDomainData'
}
}
Raphael Etim
08/23/2022, 10:29 AMPeter
08/24/2022, 12:08 AMtopics: {
create: [
{
topicalPercent: 0.514,
topicalTrustFlow: {
connectOrCreate: {
where: {topic: 'Health'},
create: {topic: 'Health'}
}
}
},
{
topicalPercent: 0.15,
topicalTrustFlow: {
connectOrCreate: {
where: {topic: 'Rec'},
create: {topic: 'Rec'}
}
}
}
]
},
Response error PrismaClientKnownRequestError:
Invalid `prisma.domain.update()` invocation:
Unique constraint failed on the (not available)
Peter
08/24/2022, 7:57 AMtopics: {
create: [
{
topicalPercent: 0.5314,
topicalTopic: {
connect: {topic: 'Health/Medicine'}
}
},
{
topicalPercent: 0.315,
topicalTopic: {
connect: {topic: 'Science'}
}
}
]
},
Peter
08/24/2022, 8:16 AMmajesticDomainData: {
upsert: {
create: {},
update: majesticDomainData,
}
}
Peter
08/24/2022, 8:19 AMmajesticDomainData: {
create: majesticDomainData,
}
I am getting this error:
The change you are trying to make would violate the required relation 'DomainToMajesticDomainData' between the `Domain` and `MajesticDomainData` models.
code: 'P2014',
clientVersion: '4.1.1',
meta: {
relation_name: 'DomainToMajesticDomainData',
model_a_name: 'Domain',
model_b_name: 'MajesticDomainData'
}
}
Peter
08/24/2022, 8:23 AMconst majesticDomainData = {
topics: {
create: [
{
topicalPercent: 0.5314,
topicalTopic: {
connect: {topic: 'Health/Medicine'}
}
},
{
topicalPercent: 0.315,
topicalTopic: {
connect: {topic: 'Science'}
}
}
]
}
}
Raphael Etim
08/24/2022, 9:03 AMNurul
08/24/2022, 10:35 AMMajesticDomainData
record without creating a domain
record.
This would result in violating one-to-one relation between them.
The change you are trying to make would violate the required relation ‘DomainToMajesticDomainData’ between theI am trying to understand what’s the exact use case that you are trying to achieve.andDomain
modelsMajesticDomainData
Peter
08/24/2022, 9:00 PMconst addDomains = await prisma.domain.createMany({
data: allDomains,
skipDuplicates: true
});
What Im trying to do is add the majesticDomainData to the domain itself
return prisma.domain.update({
where: {domain: p.domain},
data: {
majesticDomainData: {
create: majesticDomainData,
}
},
select: {
domain: true
}
})
Nurul
08/30/2022, 11:36 AM