Created
June 26, 2018 12:55
-
-
Save datafatmunger/f65261e405a25557f14e824a0c8631fb to your computer and use it in GitHub Desktop.
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 IPFS = require('ipfs') | |
| const OrbitDB = require('orbit-db') | |
| const ipfs = new IPFS({ | |
| config: { | |
| Addresses: { | |
| Swarm: [ | |
| '/dns4/wrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star' | |
| ] | |
| } | |
| } | |
| }) | |
| ipfs.on('error', (e) => console.error(e)) | |
| ipfs.on('ready', async () => { | |
| var ipfsId = await ipfs.id(); | |
| const orbitdb = new OrbitDB(ipfs) | |
| const docstore = await orbitdb.docstore(ipfsId.publicKey) | |
| var addr = docstore.address.toString(); | |
| console.log("ADDR: " + addr); | |
| docstore.put({ _id: 'hello world', doc: 'all the things' }) | |
| .then(() => docstore.put({ _id: 'sup world', doc: 'other things' })) | |
| .then(() => docstore.get('world')) | |
| .then((value) => console.log(value)) | |
| .catch((err) => console.log(err)) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment