Class: AssetRegistry

composer-client. AssetRegistry

The AssetRegistry is used to manage a set of assets stored on the blockchain.


new AssetRegistry(id, name, securityContext, modelManager, factory, serializer)

Create an asset registry.


Note: Only to be called by framework code. Applications should
retrieve instances from BusinessNetworkConnection

Parameters:
Name Type Description
id string

The unique identifier of the asset registry.

name string

The display name for the asset registry.

securityContext SecurityContext

The security context to use for this asset registry.

modelManager ModelManager

The ModelManager to use for this asset registry.

factory Factory

The factory to use for this asset registry.

serializer Serializer

The Serializer to use for this asset registry.

Source:
See:

Extends

Methods


add(resource [, options])

Add the specified resource to this registry.

Parameters:
Name Type Argument Description
resource Resource

The resource to add to this registry.

options Object <optional>

Options for processing the resources.

Properties
Name Type Argument Description
convertResourcesToRelationships boolean <optional>

Permit resources
in the place of relationships, defaults to false.

Inherited From:
Source:
Returns:

A promise that will be resolved when complete, or rejected
with an error.

Type
Promise

addAll(resources [, options])

Add all of the specified resources to this registry.

Parameters:
Name Type Argument Description
resources Array.<Resource>

The resources to add to this registry.

options Object <optional>

Options for processing the resources.

Properties
Name Type Argument Description
convertResourcesToRelationships boolean <optional>

Permit resources
in the place of relationships, defaults to false.

Inherited From:
Source:
Returns:

A promise that will be resolved when complete, or rejected
with an error.

Type
Promise

exists(id)

Determine whether the specified resource exists in this registry.

Parameters:
Name Type Description
id string

The ID of the resource.

Inherited From:
Source:
Returns:

A promise that will be resolved with a boolean
indicating whether the asset exists.

Type
Promise

get(id)

Get the specified resource in this registry.

Parameters:
Name Type Description
id string

The ID of the resource.

Inherited From:
Source:
Returns:

A promise that will be resolved with a Resource
object when complete, or rejected with an error.

Type
Promise

getAll()

Get all the resources in this registry.

Inherited From:
Source:
Returns:

A promise that will be resolved with an array of {@link
Resource} objects when complete, or rejected with an error.

Type
Promise

remove(resource)

Remove the specified resource from this registry.

Parameters:
Name Type Description
resource string | Resource

The resource to remove from this registry.

Inherited From:
Source:
Returns:

A promise that will be resolved when complete, or rejected
with an error.

Type
Promise

removeAll(resources)

Remove all of the specified resources from this registry.

Parameters:
Name Type Description
resources Array.<string> | Array.<Resource>

The resources to remove from this registry.

Inherited From:
Source:
Returns:

A promise that will be resolved when complete, or rejected
with an error.

Type
Promise

toJSON()

Return an object suitable for serialization.

Inherited From:
Source:
Returns:

An object suitable for serialization.

Type
Object

update(resource [, options])

Update the specified resource in this registry.

Parameters:
Name Type Argument Description
resource Resource

The resource to update in this registry.

options Object <optional>

Options for processing the resources.

Properties
Name Type Argument Description
convertResourcesToRelationships boolean <optional>

Permit resources
in the place of relationships, defaults to false.

Inherited From:
Source:
Returns:

A promise that will be resolved when complete, or rejected
with an error.

Type
Promise

updateAll(resources [, options])

Update all of the specified resources in this registry.

Parameters:
Name Type Argument Description
resources Array.<Resource>

The resources to update in this registry.

options Object <optional>

Options for processing the resources.

Properties
Name Type Argument Description
convertResourcesToRelationships boolean <optional>

Permit resources
in the place of relationships, defaults to false.

Inherited From:
Source:
Returns:

A promise that will be resolved when complete, or rejected
with an error.

Type
Promise