From 034afc430225aef98ecdf93214b75d049ebcb9d7 Mon Sep 17 00:00:00 2001 From: Sebastian Dechant <763247+S3bb1@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:06:18 +0200 Subject: [PATCH] fix(data-store): replace typeOrm findOne queries including relations with find (#1400) --- packages/data-store/src/data-store.ts | 4 ++-- packages/data-store/src/identifier/did-store.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/data-store/src/data-store.ts b/packages/data-store/src/data-store.ts index 310210eac..28815bc4e 100644 --- a/packages/data-store/src/data-store.ts +++ b/packages/data-store/src/data-store.ts @@ -63,7 +63,7 @@ export class DataStore implements IAgentPlugin { } async dataStoreGetMessage(args: IDataStoreGetMessageArgs): Promise { - const messageEntity = await (await getConnectedDb(this.dbConnection)).getRepository(Message).findOne({ + const [messageEntity] = await (await getConnectedDb(this.dbConnection)).getRepository(Message).find({ where: { id: args.id }, relations: ['credentials', 'presentations'], }) @@ -73,7 +73,7 @@ export class DataStore implements IAgentPlugin { } async dataStoreDeleteMessage(args: IDataStoreDeleteMessageArgs): Promise { - const messageEntity = await (await getConnectedDb(this.dbConnection)).getRepository(Message).findOne({ + const [messageEntity] = await (await getConnectedDb(this.dbConnection)).getRepository(Message).find({ where: { id: args.id }, relations: ['credentials', 'presentations'], }) diff --git a/packages/data-store/src/identifier/did-store.ts b/packages/data-store/src/identifier/did-store.ts index c9f845d57..9de577d21 100644 --- a/packages/data-store/src/identifier/did-store.ts +++ b/packages/data-store/src/identifier/did-store.ts @@ -48,7 +48,7 @@ export class DIDStore extends AbstractDIDStore { throw Error('[veramo:data-store:identifier-store] Get requires did or (alias and provider)') } - const identifier = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).findOne({ + const [identifier] = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).find({ where, relations: ['keys', 'services'], }) @@ -88,7 +88,7 @@ export class DIDStore extends AbstractDIDStore { } async deleteDID({ did }: { did: string }) { - const identifier = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).findOne({ + const [identifier] = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).find({ where: { did }, relations: ['keys', 'services', 'issuedCredentials', 'issuedPresentations'], })