Slackbot
12/20/2021, 11:17 PMChip Clark
12/21/2021, 5:01 PMPrisma.PersonRelationshipCreateInput
doesn't retain that information.Chip Clark
12/21/2021, 8:42 PM`ERROR [ExceptionsHandler] Cannot read property 'personOne' of undefined
from the following code:
async createPersonRelationship(data: createPersonRelationshipJSON) {
const PKPersonID = await this.personService.personOne(data.PKPersonID);
personOne defined in person.service.ts
personOne(id: any) {
const personID = this.prisma.person.findUnique({
where: {
PKPersonID: id
}
})
return personID;
}
I can't seem to get around the issue of sending a JSON file with the correct fields to create a new record.Chip Clark
12/21/2021, 8:51 PM[Nest] 99680 - 12/21/2021, 12:48:52 PM ERROR [ExceptionsHandler] Cannot read property '$executeRawUnsafe' of undefined
TypeError: Cannot read property '$executeRawUnsafe' of undefined
code:
async createPersonRelationship(data: createPersonRelationshipJSON) {
const insert = `
INSERT INTO [dbo].[PersonRelationship] (
[ActiveFromDate],
[ModifiedBy],
[PKPersonID],
[RelatedPersonID],
[RelationshipTypeID],
[ValidFromDate]
)
VALUES (
${data.ActiveFromDate},
${data.ModifiedBy},
${data.PKPersonID},
${data.RelatedPersonID},
${data.RelationshipTypeID},
${data.ValidFromDate},
);`;
console.log('\n\n\n' + insert + '\n\n\n');
const createResponse = this.prisma.$executeRawUnsafe(insert);
const lastId = this.prisma.$queryRaw`
SELECT @@IDENTITY as id;
`;
console.log('\n\n\n' + JSON.stringify(data) + '\n\n\n');
console.log('\n\n\n' + insert + '\n\n\n');
const [, response] = await this.prisma.$transaction([createResponse, lastId]);
return this.PersonRelationshipbyID(response?.[0]?.id );
}
data:
INSERT INTO [dbo].[PersonRelationship] (
[ActiveFromDate],
[ModifiedBy],
[PKPersonID],
[RelatedPersonID],
[RelationshipTypeID],
[ValidFromDate]
)
VALUES (
2021-12-21T00:00:00.000Z,
MDD Admin Tool,
18,
103,
1,
2021-12-21T00:00:00.000Z,
);