delete

package module
v0.1.1-0...-4a489c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Fabric Delete activity

This Flogo activity contribution can be configured to perform delete operations on Hyperledger Fabric distributed ledger and private data collections. Some delete operations are demonstrated in the contract example.

Delete one or more ledger states by state keys

This operation requires input data of one or an array of state keys, and optionally the definitions of one or more composite-keys, e.g.,

    "activity": {
        "ref": "#delete",
        "settings": {
            "compositeKeys": {
                "mapping": {
                    "color~name": ["docType", "color", "name"],
                    "owner~name": ["docType", "owner", "name"]
                }
            }
        },
        "input": "=$flow.parameters.name"
    }

This example will delete the specified state from the ledger, as well as the 2 composite keys of color~name and owner~name for the record.

Delete multiple ledger states by partial composite keys

This operation requires a composite-key definition, and input data used to construct composite-keys, e.g.,

    "activity": {
        "ref": "#delete",
        "settings": {
            "compositeKeys": {
                "mapping": {
                    "owner~name": ["docType", "owner", "name"]
                }
            }
        },
        "input": {
            "data": {
                "mapping": {
                    "@foreach($activity[get_1].result)": {
                        "docType": "=$loop.value.docType",
                        "name": "=$loop.value.name",
                        "owner": "=$loop.value.owner"
                    }
                }
            }
        }
    }

This example will collect the ledger states matching the specified composite-keys, and delete the resulting records and the associated composite keys.

Delete composite keys only

This operation requires to turn on the keysOnly flag besides a composite-key definition, and the input data used to construct composite-keys, e.g.,

    "activity": {
        "ref": "#delete",
        "settings": {
            "compositeKeys": {
                "mapping": {
                    "owner~name": ["docType", "owner", "name"]
                }
            },
            "keysOnly": true
        },
        "input": {
            "data": {
                "mapping": {
                    "@foreach($activity[get_1].result)": {
                        "docType": "=$loop.value.docType",
                        "name": "=$loop.value.name",
                        "owner": "=$loop.value.owner"
                    }
                }
            }
        }
    }

This example will delete only the matching composite keys, not the associated ledger records.

Delete data from private data collection

When a private data collection is specified in the input, data will be deleted from the specified private data collection, e.g.,

    "activity": {
        "ref": "#delete",
        "input": {
            "data": "=$flow.parameters.name",
            "privateCollection": "_implicit"
        }
    }

This example will delete a record from the client's implicit private collection, i.e., _implicit_org_<mspid>.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a new Activity

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

Activity is a stub for executing Hyperledger Fabric delete operations

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements activity.Activity.Eval

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata implements activity.Activity.Metadata

func (*Activity) String

func (a *Activity) String() string

type Input

type Input struct {
	Data              interface{} `md:"data"`
	PrivateCollection string      `md:"privateCollection"`
}

Input of the activity

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

FromMap sets activity input values from a map

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

ToMap converts activity input to a map

type Output

type Output struct {
	Code    int           `md:"code"`
	Message string        `md:"message"`
	Result  []interface{} `md:"result"`
}

Output of the activity

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

FromMap sets activity output values from a map

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

ToMap converts activity output to a map

type Settings

type Settings struct {
	CompositeKeys map[string][]string `md:"compositeKeys"`
	KeysOnly      bool                `md:"keysOnly"`
}

Settings of the activity

func (*Settings) FromMap

func (h *Settings) FromMap(values map[string]interface{}) error

FromMap sets settings from a map construct composite key definition of format {"index": ["field1, "field2"]}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL