Update README and getting started guide

This commit is contained in:
haad 2023-08-24 17:13:29 +03:00
parent 77bd2734a6
commit d4918e750a
2 changed files with 24 additions and 26 deletions

View File

@ -35,14 +35,14 @@ A Go implementation is developed and maintained by the [Berty](https://github.co
- [Installation](#installation) - [Installation](#installation)
* [Browser <script> tag](#browser-script-tag) * [Browser <script> tag](#browser-script-tag)
- [Usage](#usage) - [Usage](#usage)
- [API](#api) - [Documentation](#documentation)
* [API](#api)
- [Development](#development) - [Development](#development)
* [Run Tests](#run-tests) * [Run Tests](#run-tests)
* [Build](#build) * [Build](#build)
* [Benchmark](#benchmark) * [Benchmark](#benchmark)
* [API](#api) * [API](#api)
- [Frequently Asked Questions](#frequently-asked-questions) - [Are there implementations in other languages?](#other-implementations)
* [Are there implementations in other languages?](#are-there-implementations-in-other-languages)
- [Contributing](#contributing) - [Contributing](#contributing)
- [Sponsors](#sponsors) - [Sponsors](#sponsors)
- [License](#license) - [License](#license)
@ -51,8 +51,10 @@ A Go implementation is developed and maintained by the [Berty](https://github.co
## Installation ## Installation
Note! The upcoming version 1.0.0 is currently in testing and needs to be installed as version "next" as described below.
``` ```
npm install @orbitdb/core npm install @orbitdb/core@next
``` ```
### Browser <script> tag ### Browser <script> tag
@ -102,11 +104,13 @@ import { createOrbitDB } from '@orbitdb/core'
})() })()
``` ```
## Documentation
Use the **[Getting Started](https://github.com/orbitdb/orbitdb/docs/GETTING_STARTED.md)** guide for an initial introduction to OrbitDB and you can find more advanced topics covered in our [docs](https://github.com/orbitdb/orbitdb/docs). Use the **[Getting Started](https://github.com/orbitdb/orbitdb/docs/GETTING_STARTED.md)** guide for an initial introduction to OrbitDB and you can find more advanced topics covered in our [docs](https://github.com/orbitdb/orbitdb/docs).
## API ### API
See [API.md](https://github.com/orbitdb/orbitdb/blob/master/API.md) for the full documentation. See [api.orbitdb.org](https://api.orbitdb.org) for the full API documentation.
## Development ## Development
@ -137,18 +141,12 @@ npm run build:docs
Documentation is output to ./docs/api. Documentation is output to ./docs/api.
## Frequently Asked Questions ## Other implementations
We have an FAQ! [Go take a look at it](FAQ.md). If a question isn't there, open an issue and suggest adding it. We can work on the best answer together. - Golang: [berty/go-orbit-db](https://github.com/berty/go-orbit-db)
- Python: [orbitdb/py-orbit-db-http-client](https://github.com/orbitdb/py-orbit-db-http-client)
### Are there implementations in other languages? If you know of any other repos that ought to be included in this section, please open a PR and add them.
Yes! Take a look at these implementations:
- Golang: [berty/go-orbit-db](https://github.com/berty/go-orbit-db)
- Python: [orbitdb/py-orbit-db-http-client](https://github.com/orbitdb/py-orbit-db-http-client)
The best place to find out what is out there and what is being actively worked on is likely by asking in the [Matrix](https://app.element.io/#/room/#orbit-db:matrix.org). If you know of any other repos that ought to be included in this section, please open a PR and add them.
## Contributing ## Contributing

View File

@ -7,7 +7,7 @@ This guide will help you get up and running with a simple OrbitDB database that
Install OrbitDB: Install OrbitDB:
```sh ```sh
npm i orbit-db npm i @orbitdb/core@next
``` ```
You will also need IPFS for replication: You will also need IPFS for replication:
@ -122,7 +122,7 @@ import { create } from 'ipfs-core'
const main = async () => { const main = async () => {
// create a random directory to avoid IPFS and OrbitDB conflicts. // create a random directory to avoid IPFS and OrbitDB conflicts.
let randDir = (Math.random() + 1).toString(36).substring(2); let randDir = (Math.random() + 1).toString(36).substring(2)
const config = { const config = {
Addresses: { Addresses: {
@ -138,7 +138,7 @@ const main = async () => {
// This will create all OrbitDB-related databases (keystore, my-db, etc) in // This will create all OrbitDB-related databases (keystore, my-db, etc) in
// ./[randDir]/ipfs. // ./[randDir]/ipfs.
const orbitdb = await createOrbitDB({ ipfs, directory: './' + randDir + '/orbitdb' }) const orbitdb = await createOrbitDB({ ipfs, directory: './' + randDir + '/orbitdb' })
// Get the IPFS AccessController function. We will need it to ensure everyone // Get the IPFS AccessController function. We will need it to ensure everyone
// can write to the database. // can write to the database.
const AccessController = getAccessController('ipfs') const AccessController = getAccessController('ipfs')
@ -146,7 +146,7 @@ const main = async () => {
let db let db
if (process.argv[2]) { if (process.argv[2]) {
db = await orbitdb.open(process.argv[2]) db = await orbitdb.open(process.argv[2])
} else { } else {
// When we open a new database, write access is only available to the // When we open a new database, write access is only available to the
// db creator. When replicating a database on a remote peer, the remote // db creator. When replicating a database on a remote peer, the remote
@ -156,16 +156,16 @@ const main = async () => {
// revoke. // revoke.
db = await orbitdb.open('my-db', { AccessController: AccessController({ write: ['*']})}) db = await orbitdb.open('my-db', { AccessController: AccessController({ write: ['*']})})
} }
// Copy this output if you want to connect a peer to another. // Copy this output if you want to connect a peer to another.
console.log('my-db address', db.address) console.log('my-db address', db.address)
// Add some records to the db when another peers joins. // Add some records to the db when another peers joins.
db.events.on('join', async (peerId, heads) => { db.events.on('join', async (peerId, heads) => {
await db.add('hello world 1') await db.add('hello world 1')
await db.add('hello world 2') await db.add('hello world 2')
}) })
db.events.on('update', async (entry) => { db.events.on('update', async (entry) => {
console.log('entry', entry) console.log('entry', entry)
@ -179,8 +179,8 @@ const main = async () => {
await db.close() await db.close()
await orbitdb.stop() await orbitdb.stop()
await ipfs.stop() await ipfs.stop()
process.exit() process.exit()
}) })
} }