Documentation
¶
Overview ¶
Package orm provides a simple wrapper for Hyperledger Fabric tables.
Add an anonymous field orm.Saveable to your entities. At initialization, create a table as follows:
user := new(User)
if err := orm.CreateTable(stub, user); err != nil {
return nil, errors.Wrap(err, "Failed creating table.")
}
For more info, see the README.md on github
Index ¶
- func Create(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
- func CreateTable(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
- func Delete(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
- func Get(stub shim.ChaincodeStubInterface, item BlockchainItemizer, id int64) error
- func GetAll(stub shim.ChaincodeStubInterface, items interface{}) error
- func Update(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
- type BlockchainItemizer
- type Saveable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
Insert a row for the item in the database
func CreateTable ¶
func CreateTable(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
Create a table of the passed item. Types are automatically inferred.
func Delete ¶
func Delete(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
Delete an item
func Get ¶
func Get(stub shim.ChaincodeStubInterface, item BlockchainItemizer, id int64) error
Get an item by Id
func GetAll ¶
func GetAll(stub shim.ChaincodeStubInterface, items interface{}) error
Get all items by passing a slice of the correct type
func Update ¶
func Update(stub shim.ChaincodeStubInterface, item BlockchainItemizer) error
Update an item
Types ¶
type BlockchainItemizer ¶
Items need to implement this interface to use ORM. You can use an anonymous Saveable in your struct.
Click to show internal directories.
Click to hide internal directories.