This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Submitted for verification at Etherscan.io on 2020-04-01 | |
*/ | |
pragma solidity ^0.5.0; | |
/** | |
* @dev Contract module which provides a basic access control mechanism, where | |
* there is an account (an owner) that can be granted exclusive access to | |
* specific functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Submitted for verification at Etherscan.io on 2020-04-01 | |
*/ | |
pragma solidity ^0.5.0; | |
/** | |
* @dev Contract module which provides a basic access control mechanism, where | |
* there is an account (an owner) that can be granted exclusive access to | |
* specific functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Submitted for verification at Etherscan.io on 2020-04-01 | |
*/ | |
pragma solidity ^0.5.0; | |
/** | |
* @dev Contract module which provides a basic access control mechanism, where | |
* there is an account (an owner) that can be granted exclusive access to | |
* specific functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Using AvionDB in Browser--> | |
<!--IPFS CDN Link--> | |
<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"></script> | |
<!--AvionDB CDN Link--> | |
<script src="https://unpkg.com/aviondb/dist/aviondb.min.js"></script> | |
<script type="text/javascript"> | |
const runExample = async () => { | |
const ipfs = await window.Ipfs.create(); | |
// Creates a db named "DatabaseName" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import modules | |
const AvionDB = require("aviondb"); | |
const IPFS = require("ipfs"); | |
const ipfs = new IPFS(); | |
const runExample = async () => { | |
await ipfs.ready; | |
// Creates a db named "DatabaseName" | |
const aviondb = await AvionDB.init("DatabaseName", ipfs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch the details by reading the DAG for key "inputKey" | |
fmt.Printf("READ: Reading the document details of employee by ID: \"%s\"\n", inputID) | |
start = time.Now() | |
document, err := GetDocument(cid, inputID) | |
elapsed = time.Since(start) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Printf("READ: Salary of employee ID %s is %s\n", string(inputID), string(document.Salary)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GetDocument handles READ operations of a DAG entry by CID, returning the corresponding document | |
func GetDocument(ref, key string) (out SampleStruct, err error) { | |
err = sh.DagGet(ref+"/"+key, &out) | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Map the struct instance to the mapping | |
DocStoreMap[inputID] = employeeObject | |
// Converting the map into JSON object | |
entryJSON, err := json.Marshal(DocStoreMap) | |
if err != nil { | |
fmt.Println(err) | |
} | |
// Display the marshaled JSON object before sending it to IPFS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scanner := bufio.NewScanner(os.Stdin) | |
fmt.Println("Enter the ID of the employee: ") | |
scanner.Scan() | |
inputID := scanner.Text() | |
fmt.Println("Enter the name of the employee: ") | |
scanner.Scan() | |
inputName := scanner.Text() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Map the struct instance its own ID | |
DocStoreMap := make(map[string]SampleStruct) |
NewerOlder