Skip to content

Commit

Permalink
fix(data-store-orm): remove double entries
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <mirko.mollik@fit.fraunhofer.de>
  • Loading branch information
cre8 committed Dec 8, 2023
1 parent 462735d commit 85be779
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/data-store/src/data-store-orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ export class DataStoreORM implements IAgentPlugin {
context: AuthorizedDIDContext,
): Promise<Array<UniqueVerifiableCredential>> {
const claims = await (await this.claimsQuery(args, context)).getMany()
return claims.map((claim) => ({
hash: claim.credential.hash,
verifiableCredential: claim.credential.raw,
}))
return claims
.map((claim) => ({
hash: claim.credential.hash,
verifiableCredential: claim.credential.raw,
}))
.reduce((acc: UniqueVerifiableCredential[], current: UniqueVerifiableCredential) => {
if (!acc.some((item) => item.hash === current.hash)) {
acc.push(current)
}
return acc
}, [])
}

async dataStoreORMGetVerifiableCredentialsByClaimsCount(
Expand Down

0 comments on commit 85be779

Please sign in to comment.