This file contains hidden or 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
Car.deleteById('Audi A4', function (err, success) { | |
if (!err) { | |
console.log('object deleted successfully'); | |
} | |
}); |
This file contains hidden or 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
Car.findById('Audi A4', function (err, record) { | |
if (!err) { | |
console.log(record); | |
} | |
}); |
This file contains hidden or 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
Car.find(function (err, allRecords) { | |
if (!err) { | |
console.log(allRecords); | |
} | |
}); |
This file contains hidden or 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
var newCarObject = {model:'Audi A4', engine: 'V8', wheels: 4}; | |
Car.save(newCarObject, function (err, objectSaved) { | |
if (!err) { | |
console.log('object saved'); | |
} | |
}) |
This file contains hidden or 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
Car.deploy(function (err, success) { | |
if (!err) { | |
console.log('Deployed successfully'); | |
} | |
}); |
This file contains hidden or 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
var ethAirBalloons = require('ethairballoons'); | |
var path = require('path'); | |
var savePath = path.resolve(__dirname + '/contracts'); | |
var ethAirBalloonsProvider = ethAirBalloons('http://localhost:8545', savePath); | |
//ethereum blockchain provider URL, path to save auto generated smart contracts | |
var Car = ethAirBalloonsProvider.createSchema({ | |
name: "Car", | |
contractName: "carsContract", |
This file contains hidden or 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
return ( | |
<div className="App"> | |
<div style={{width: '270px', overflowY: 'scroll', margin: 'auto'}}> | |
{checkboxItems()} | |
<p>{state.selections.toString()}</p> | |
</div> | |
</div> | |
); |
This file contains hidden or 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
function handleCheckboxChange(key: string) { | |
let sel = state.selections | |
let find = sel.indexOf(key) | |
if (find > -1) { | |
sel.splice(find, 1) | |
} else { | |
sel.push(key) | |
} | |
setState({ |
This file contains hidden or 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
function checkboxItems() { | |
return ( | |
<React.Fragment> | |
{options.map((option) => ( | |
<ListItem | |
key={option} | |
text={option} | |
handleOnChange={() => handleCheckboxChange(option)} | |
selected={state.selections.includes(option)} | |
></ListItem> |
This file contains hidden or 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
const [state, setState] = React.useState<{ selections: string[] }>({ selections: [] }); | |
const options = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7', 'Item 8', 'Item 9'] |