Chip Clark
03/15/2022, 7:48 PMmodel Email {
EmailID Int @id @default(autoincrement()) @db.Int
EntityID? Int @db.Int
EntityTypeID Int @db.TinyInt
EmailAddress String @db.VarChar(50)
EmailTypeID Int @db.Int
Description String? @db.VarChar(100)
Active Boolean? @default(false) @db.Bit
ActiveFromDate DateTime @db.Date
ModifiedDate DateTime? @default(now()) @db.DateTime
ModifiedBy String @db.VarChar(30)
ValidFromDate DateTime? @db.DateTime2
ValidToDate DateTime? @db.DateTime2
EmailType EmailType? @relation(fields: [EmailTypeID], references: [EmailTypeID])
/// One to many relation with Person Entity through EntityID <-> PKPersonID
Person Person? @relation(fields: [EntityID], references: [PKPersonID])
}
Getting data isn't a problem, but when I try and Create a new email for an existing person:
JSON sent to API server
const tempEmailBody = {
'EntityID:': PKPersonID,
'EntityTypeID': 1,
'EmailAddress': email,
"ActiveFromDate": this.currentDate,
"ModifiedDate": this.currentDate,
"ModifiedBy": "MDD Admin Tool - modified",
'Active': true
}
I get an error:
Unknown arg `EntityID:` in data.EntityID: for type EmailCreateInput. Did you mean `EntityTypeID`? Available args:
type EmailCreateInput {
EntityTypeID: Int
EmailAddress: String
Description?: String | Null
Active?: Boolean | Null
ActiveFromDate: DateTime
ModifiedDate?: DateTime | Null
ModifiedBy: String
ValidFromDate?: DateTime | Null
ValidToDate?: DateTime | Null
EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
Person?: PersonCreateNestedOneWithoutEmailInput
if I try and use Person
const tempEmailBody = {
'Person:': PKPersonID,
'EntityTypeID': 1,
'EmailAddress': email,
"ActiveFromDate": this.currentDate,
"ModifiedDate": this.currentDate,
"ModifiedBy": "MDD Admin Tool - modified",
'Active': true
}
I get the error:
Unknown arg `Person:` in data.Person: for type EmailCreateInput. Did you mean `Person`? Available args:
type EmailCreateInput {
EntityTypeID: Int
EmailAddress: String
Description?: String | Null
Active?: Boolean | Null
ActiveFromDate: DateTime
ModifiedDate?: DateTime | Null
ModifiedBy: String
ValidFromDate?: DateTime | Null
ValidToDate?: DateTime | Null
EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
Person?: PersonCreateNestedOneWithoutEmailInput
}
IF I try and build something that creates a PersonWhereUniqueInput
const tempEmailBody = {
'Person:': {'PersonWhereUniqueInput': {PKPersonID: this.onePerson.PKPersonID} },
'EntityTypeID': 1,
'EmailAddress': email,
"ActiveFromDate": this.currentDate,
"ModifiedDate": this.currentDate,
"ModifiedBy": "MDD Admin Tool - modified",
'Active': true
}
I get the error:
Unknown arg `Person:` in data.Person: for type EmailCreateInput. Did you mean `Person`? Available args:
type EmailCreateInput {
EntityTypeID: Int
EmailAddress: String
Description?: String | Null
Active?: Boolean | Null
ActiveFromDate: DateTime
ModifiedDate?: DateTime | Null
ModifiedBy: String
ValidFromDate?: DateTime | Null
ValidToDate?: DateTime | Null
EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
Person?: PersonCreateNestedOneWithoutEmailInput
}
Chip Clark
03/15/2022, 10:51 PM{
"EntityTypeID": 1,
"EmailAddress": "<mailto:bbarker@allenmatkins.com|bbarker@allenmatkins.com>",
"ActiveFromDate": "2022-03-15T00:00:00.000Z",
"ModifiedDate": "2022-03-15T00:00:00.000Z",
"ModifiedBy": "MDD Admin Tool - modified",
"Active": true
}
I get THIS error:
Invalid `this.prisma.email.create()` invocation in
C:\Sites\AM-API-MDD\src\app\email\email.service.ts:59:30
56 }
57
58 async createEmail(data: Prisma.EmailCreateInput) {
ā 59 return this.prisma.email.create(
Null constraint violation on the fields: (`EntityID`)
I understand why it complains when there is no EntityID, but I don't understand why I get an error when I do send one: Unknown arg 'EntityID:' in data.EntityID:janpio
:
in your object key names intentional?janpio
const tempEmailBody = {
'EntityID:': PKPersonID,
^
'EntityTypeID': 1,
maybe be
const tempEmailBody = {
'EntityID': PKPersonID,
'EntityTypeID': 1,