Class

FabricContractRepository

FabricContractRepository(adapteropt, clazzopt, trackedEventsopt)

Constructor

# new FabricContractRepository(adapteropt, clazzopt, trackedEventsopt)

Provides CRUD operations for models within Fabric chaincode contracts

Repository for Hyperledger Fabric chaincode models

sequenceDiagram participant Contract participant Repository participant Adapter participant StateDB Contract->>Repository: create(model, ctx) Repository->>Adapter: prepare(model, pk) Repository->>Adapter: create(tableName, id, record, transient, ctx) Adapter->>StateDB: putState(id, serializedData) StateDB-->>Adapter: Success Adapter-->>Repository: record Repository->>Adapter: revert(record, class, pk, id, transient) Adapter-->>Repository: model Repository-->>Contract: model
Parameters:
Name Type Attributes Description
adapter FabricContractAdapter <optional>

The adapter for interacting with the state database

clazz Constructor.<M> <optional>

The model constructor

trackedEvents Array.<(OperationKeys|BulkCrudOperationKeys|string)> <optional>

Events to track for observer notifications

View Source contracts/FabricContractRepository.ts, line 4

Example
```typescript
// In a Fabric chaincode contract class
import { FabricContractRepository, FabricContractAdapter } from '@decaf-ts/for-fabric';

Methods

# ObserverHandler() → {ObserverHandler}

Returns a FabricContractRepositoryObservableHandler instance

Gets the observer handler for this repository

View Source contracts/FabricContractRepository.ts, line 112

The observer handler

ObserverHandler

# async updateObservers(table, event, id, ctx, …args) → {Promise.<void>}

Filters events based on trackedEvents and delegates to the parent method

Updates observers based on tracked events

Parameters:
Name Type Attributes Description
table string

The table/collection name

event OperationKeys | BulkCrudOperationKeys | string

The event type

id EventIds

The event identifier

ctx FabricContractContext

The Fabric contract context

args Array.<any> <repeatable>

Additional arguments

View Source contracts/FabricContractRepository.ts, line 125

Promise that resolves when observers are updated

Promise.<void>