Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@orbitdb/core
Advanced tools
OrbitDB is a serverless, distributed, peer-to-peer database. OrbitDB uses IPFS as its data storage and Libp2p Pubsub to automatically sync databases with peers. It's an eventually consistent database that uses Merkle-CRDTs for conflict-free database writes and merges making OrbitDB an excellent choice for p2p and decentralized apps, blockchain applications and local-first web applications.
OrbitDB provides various types of databases for different data models and use cases:
All databases are implemented on top of OrbitDB's OpLog, an immutable, cryptographically verifiable, operation-based conflict-free replicated data structure (CRDT) for distributed systems. OpLog is formalized in the paper Merkle-CRDTs. You can also easily extend OrbitDB by implementing and using a custom data model benefitting from the same properties as the default data models provided by the underlying Merkle-CRDTs.
This is the Javascript implementation and it works both in Browsers and Node.js with support for Linux, OS X, and Windows.
A Go implementation is developed and maintained by the Berty project at berty/go-orbit-db.
Install OrbitDB and its dependencies:
npm install @orbitdb/core helia
OrbitDB can be loaded in the browser using the distributed js file with the <script/>
tag. OrbitDB is the global namespace and all external functions are available via this namespace:
<script>/path/to/orbitdb.min.js</script>
If you want to get up and running with OrbitDB quickly, install and follow the instructions in the @orbitdb/quickstart module.
If you're using @orbitdb/core
to develop browser or Node.js applications, use it as a module with the javascript instance of IPFS.
import { createHelia } from 'helia'
import { createOrbitDB } from '@orbitdb/core'
import { gossipsub } from "@chainsafe/libp2p-gossipsub";
import { identify } from "@libp2p/identify";
import { createLibp2p } from 'libp2p'
const Libp2pOptions = {
services: {
pubsub: gossipsub({
// neccessary to run a single peer
allowPublishToZeroPeers: true
}),
identify: identify()
}
}
;(async function () {
const libp2p = await createLibp2p({ ...Libp2pOptions })
const ipfs = await createHelia({libp2p})
const orbitdb = await createOrbitDB({ ipfs })
// Create / Open a database. Defaults to db type "events".
const db = await orbitdb.open("hello")
const address = db.address
console.log(address)
// "/orbitdb/zdpuAkstgbTVGHQmMi5TC84auhJ8rL5qoaNEtXo2d5PHXs2To"
// The above address can be used on another peer to open the same database
// Listen for updates from peers
db.events.on("update", async entry => {
console.log(entry)
const all = await db.all()
console.log(all)
})
// Add an entry
const hash = await db.add("world")
console.log(hash)
// Query
for await (const record of db.iterator()) {
console.log(record)
}
await db.close()
await orbitdb.stop()
await ipfs.stop()
})()
To configure your IPFS instance for persistency and Libp2p to connect to peers, see Creating a Helia instance and the Default Libp2p Configurations in @orbitdb/quickstart for examples.
Use the Getting Started guide for an initial introduction to OrbitDB.
You can find more advanced topics in our docs covering:
See https://api.orbitdb.org for the full API documentation.
npm run test
npm run build
node benchmarks/orbitdb-events.js
See benchmarks/ for more benchmarks.
To build the API documentation, run:
npm run build:docs
Documentation is output to ./docs/api.
If you know of any other repos that ought to be included in this section, please open a PR and add them.
Take a look at our organization-wide Contributing Guide. You'll find most of your questions answered there.
If you want to code but don't know where to start, check out the issues labelled "help wanted".
The development of OrbitDB has been sponsored by:
If you want to sponsor developers to work on OrbitDB, please donate to our OrbitDB Open Collective or reach out to @haadcode.
MIT © 2015-2023 Protocol Labs Inc., Haja Networks Oy, OrbitDB Community
FAQs
Distributed p2p database on IPFS
The npm package @orbitdb/core receives a total of 394 weekly downloads. As such, @orbitdb/core popularity was classified as not popular.
We found that @orbitdb/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.