mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
docs: Migrate js-ipfs examples to Helia.
This commit is contained in:
parent
64e36df5a1
commit
a7ec7b7b41
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OrbitDB API - v1.0</title>
|
||||
<title>OrbitDB API - v2.0</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
|
@ -89,7 +89,7 @@ The identity object is stored like any other [IPLD data structure](https://ipld.
|
||||
|
||||
```js
|
||||
import { createLibp2p } from 'libp2p'
|
||||
import { createHelia } from 'helia' from 'ipfs-core'
|
||||
import { createHelia } from 'helia'
|
||||
import * as Block from 'multiformats/block'
|
||||
import { Identities } from '@orbitdb/core'
|
||||
import * as dagCbor from '@ipld/dag-cbor'
|
||||
|
@ -9,19 +9,21 @@ To install OrbitDB:
|
||||
npm install @orbitdb/core
|
||||
```
|
||||
|
||||
IPFS is also required:
|
||||
Helia, the Javascript version of IPFS, is also required:
|
||||
|
||||
```bash
|
||||
npm install ipfs-core
|
||||
npm install helia
|
||||
```
|
||||
|
||||
Instantiate OrbitDB and create a database:
|
||||
|
||||
```js
|
||||
import { create } from 'ipfs-core'
|
||||
import { createLibp2p } from 'libp2p'
|
||||
import { createHelia } from 'helia'
|
||||
import { createOrbitDB } from '@orbitdb/core'
|
||||
|
||||
const ipfs = await create() // IPFS is required for storage and network communication
|
||||
const libp2p = await createLibp2p({ /* Libp2p options */ })
|
||||
const ipfs = await createHelia({ libp2p }) // Helia is required for storage and network communication
|
||||
const orbitdb = await createOrbitDB({ ipfs })
|
||||
const mydb = await orbitdb.open('mydb')
|
||||
console.log(mydb.address) // /orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13
|
||||
@ -32,10 +34,12 @@ Open and replicate an existing database:
|
||||
|
||||
```js
|
||||
// In another process
|
||||
import { create } from 'ipfs-core'
|
||||
import { createLibp2p } from 'libp2p'
|
||||
import { createHelia } from 'helia'
|
||||
import { createOrbitDB } from '@orbitdb/core'
|
||||
|
||||
const ipfs = await create()
|
||||
const libp2p = await createLibp2p({ /* Libp2p options */ })
|
||||
const ipfs = await createHelia({ libp2p }) // Helia is required for storage and network
|
||||
const orbitdb = await createOrbitDB({ ipfs })
|
||||
const theirdb = await orbitdb.open('/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13')
|
||||
for await (let record of theirdb.iterator()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user