Skip to content

Commit

Permalink
fix: IdentityStore
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat authored and mirceanis committed Sep 7, 2020
1 parent 2bc4084 commit 53eb972
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/daf-typeorm/src/identity/identity-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import { AbstractIdentityStore, IIdentity } from 'daf-core'
import { Identity } from '../entities/identity'
import { Key } from '../entities/key'
import { Service } from '../entities/service'
import { Connection } from 'typeorm'
import { Connection, IsNull, Not } from 'typeorm'

import Debug from 'debug'
const debug = Debug('daf:typeorm:identity-store')

export class IdentityStore extends AbstractIdentityStore {

constructor(private dbConnection: Promise<Connection>) {
super()
}

async get({ did, alias }: { did: string, alias?: string }): Promise<IIdentity> {
async get({ did, alias }: { did: string; alias?: string }): Promise<IIdentity> {
//TODO alias
const identity = await (await this.dbConnection)
.getRepository(Identity)
Expand All @@ -36,7 +35,7 @@ export class IdentityStore extends AbstractIdentityStore {
identity.did = args.did
identity.controllerKeyId = args.controllerKeyId
identity.provider = args.provider

identity.keys = []
for (const argsKey of args.keys) {
const key = new Key()
Expand Down Expand Up @@ -65,9 +64,10 @@ export class IdentityStore extends AbstractIdentityStore {
}

async list(): Promise<IIdentity[]> {
const identities = await (await this.dbConnection)
.getRepository(Identity)
.find({ relations: ['keys', 'services'] })
const identities = await (await this.dbConnection).getRepository(Identity).find({
where: [{ provider: Not(IsNull()) }],
relations: ['keys', 'services'],
})
return identities
}
}

0 comments on commit 53eb972

Please sign in to comment.