Skip to content

Commit

Permalink
feat: add delete methods to services and modules (#447)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Aug 31, 2021
1 parent 55c0fa0 commit e7ed602
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core/src/modules/connections/ConnectionsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ export class ConnectionsModule {
return this.connectionService.findById(connectionId)
}

/**
* Delete a connection record by id
*
* @param connectionId the connection record id
*/
public async deleteById(connectionId: string) {
return this.connectionService.deleteById(connectionId)
}

/**
* Find connection by verkey.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ export class ConnectionService {
return this.connectionRepository.findById(connectionId)
}

/**
* Delete a connection record by id
*
* @param connectionId the connection record id
*/
public async deleteById(connectionId: string) {
const connectionRecord = await this.getById(connectionId)
return this.connectionRepository.delete(connectionRecord)
}

/**
* Find connection by verkey.
*
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/modules/credentials/CredentialsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ export class CredentialsModule {
return this.credentialService.findById(connectionId)
}

/**
* Delete a credential record by id
*
* @param credentialId the credential record id
*/
public async deleteById(credentialId: string) {
return this.credentialService.deleteById(credentialId)
}

private registerHandlers(dispatcher: Dispatcher) {
dispatcher.registerHandler(
new ProposeCredentialHandler(this.credentialService, this.agentConfig, this.credentialResponseCoordinator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,16 @@ export class CredentialService {
return this.credentialRepository.findById(connectionId)
}

/**
* Delete a credential record by id
*
* @param credentialId the credential record id
*/
public async deleteById(credentialId: string) {
const credentialRecord = await this.getById(credentialId)
return this.credentialRepository.delete(credentialRecord)
}

/**
* Retrieve a credential record by connection id and thread id
*
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/modules/proofs/ProofsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,15 @@ export class ProofsModule {
return this.proofService.findById(proofRecordId)
}

/**
* Delete a proof record by id
*
* @param proofId the proof record id
*/
public async deleteById(proofId: string) {
return this.proofService.deleteById(proofId)
}

private registerHandlers(dispatcher: Dispatcher) {
dispatcher.registerHandler(
new ProposePresentationHandler(this.proofService, this.agentConfig, this.proofResponseCoordinator)
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/modules/proofs/services/ProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,16 @@ export class ProofService {
return this.proofRepository.findById(proofRecordId)
}

/**
* Delete a proof record by id
*
* @param proofId the proof record id
*/
public async deleteById(proofId: string) {
const proofRecord = await this.getById(proofId)
return this.proofRepository.delete(proofRecord)
}

/**
* Retrieve a proof record by connection id and thread id
*
Expand Down

0 comments on commit e7ed602

Please sign in to comment.