# new FabricCrudContract()
Provides standard create, read, update, and delete operations for models in Fabric chaincode
Base contract class for CRUD operations in Fabric chaincode
Example
```typescript
// Define a model
Extends
- Contract
Classes
- FabricCrudContract
Initializes a contract with a name and model class
- FabricCrudContract
Initializes a contract with a name and model class
Members
# adapter
Shared adapter instance for all contract instances
.Shared adapter instance for all contract instances
FabricContractAdapter
# protected static adapter
Shared adapter instance for all contract instances
.Shared adapter instance for all contract instances
Methods
# async create(ctx, model, …args) → {Promise.<M>}
Delegates to the repository's create method
Creates a single model in the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
model |
M
|
The model to create |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the created model
Promise.<M>
# async createAll(ctx, models, …args) → {Promise.<Array.<M>>}
Delegates to the repository's createAll method
Creates multiple models in the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
models |
Array.<M>
|
The models to create |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the created models
Promise.<Array.<M>>
# async delete(ctx, key, …args) → {Promise.<M>}
Delegates to the repository's delete method
Deletes a single model from the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
key |
string
|
number
|
The key of the model to delete |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the deleted model
Promise.<M>
# async deleteAll(keys, ctx, …args) → {Promise.<Array.<M>>}
Delegates to the repository's deleteAll method
Deletes multiple models from the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
keys |
Array.<string>
|
Array.<number>
|
The keys of the models to delete |
|
ctx |
Ctx
|
The Fabric chaincode context |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the deleted models
Promise.<Array.<M>>
# async raw(ctx, rawInput, docsOnly, …args) → {Promise.<any>}
Delegates to the repository's raw method
Executes a raw query against the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
rawInput |
any
|
The query to execute |
|
docsOnly |
boolean
|
Whether to return only documents |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the query results
Promise.<any>
# async read(ctx, key, …args) → {Promise.<M>}
Delegates to the repository's read method
Reads a single model from the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
key |
string
|
number
|
The key of the model to read |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the retrieved model
Promise.<M>
# async readAll(ctx, keys, …args) → {Promise.<Array.<M>>}
Delegates to the repository's readAll method
Reads multiple models from the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
keys |
Array.<string>
|
Array.<number>
|
The keys of the models to read |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the retrieved models
Promise.<Array.<M>>
# async update(ctx, model, …args) → {Promise.<M>}
Delegates to the repository's update method
Updates a single model in the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
model |
M
|
The model to update |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the updated model
Promise.<M>
# async updateAll(ctx, models, …args) → {Promise.<Array.<M>>}
Delegates to the repository's updateAll method
Updates multiple models in the state database
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ctx |
Ctx
|
The Fabric chaincode context |
|
models |
Array.<M>
|
The models to update |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments |
Promise resolving to the updated models
Promise.<Array.<M>>