npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dashevo/dapi-db

v0.19.9

Published

Distributed p2p database on IPFS

Downloads

9

Readme

DapiDB

CircleCI Status npm version node Project Status

A peer-to-peer database for the decentralized web

DapiDB is a serverless, distributed, peer-to-peer database. DapiDB uses IPFS as its data storage and IPFS Pubsub to automatically sync databases with peers. It's an eventually consistent database that uses CRDTs for conflict-free database merges making DapiDB an excellent choice for decentralized apps (dApps), blockchain applications and offline-first web applications.

Data in DapiDB can be stored in a

This is the Javascript implementation and it works both in Node.js and Browsers.

To get started, try the DapiDB CLI, read the Getting Started Guide or check Live demo 1, Live demo 2 or P2P TodoMVC app!

Table of Contents

Usage

Read the GETTING STARTED guide for a more in-depth tutorial and to understand how DapiDB works.

DapiDB currently supports Linux and OS X, Windows is not supported yet.

CLI

For the CLI tool to manage orbit-db database, see DapiDB CLI.

It can be installed from Npm with:

npm install orbit-db-cli -g

As a library

Install dependencies:

npm install orbit-db ipfs

Use it as a module:

const IPFS = require('ipfs')
const DapiDB = require('orbit-db')

// DapiDB uses Pubsub which is an experimental feature
// and need to be turned on manually.
// Note that these options need to be passed to IPFS in 
// all examples even if not specfied so.
const ipfsOptions = {
  EXPERIMENTAL: {
    pubsub: true
  },
}

// Create IPFS instance
const ipfs = new IPFS(ipfsOptions)

ipfs.on('error', (e) => console.error(e))
ipfs.on('ready', async () => {
  // Create a database
  const dapidb = new DapiDB(ipfs)
  const db = await dapidb.log('database name')
  // Add an entry to the database
  const hash = await db.add('hello world')
  // Get last 5 entries
  const latest = db.iterator({ limit: 5 }).collect()
  console.log(JSON.stringify(latest, null, 2))
})

For more details, see examples for kvstore, eventlog, feed, docstore and counter.

The minimum required version of Node.js is now 8.0.0. To use with older versions of Node.js, we provide an ES5-compatible build through the npm package, located in dist/es5/ when installed through npm.

API

See API documentation for the full documentation.

Examples

Install dependencies

git clone https://github.com/dashevo/dapi-db.git
cd orbit-db
npm install

You'll also need babel and webpack, if you don't have them installed already:

npm install --global babel-cli
npm install --global webpack

Some dependencies depend on native addon modules, so you'll also need to meet node-gyp's installation prerequisites. Therefore, Linux users may need to

make clean && make

to redo the local package-lock.json with working native dependencies.

Browser example

In macOS:

npm run build
npm run examples:browser-macos

In Linux:

npm run build
npm run examples:browser-linux

Check the code in examples/browser/browser.html and try the live example.

Node.js example

npm run examples:node

Eventlog

See the code in examples/eventlog.js and run it with:

node examples/eventlog.js

More examples at examples.

Custom Store Types

You can add custom store types to DapiDB:

// define custom store type
class CustomStore extends DocumentStore {
  constructor (ipfs, id, dbname, options) {
    super(ipfs, id, dbname, options)
    this._type = CustomStore.type
  }

  static get type () {
    return 'custom'
  }
}

// add custom type to dapidb
DapiDB.addDatabaseType(CustomStore.type, CustomStore)

// instantiate custom store
let dapidb = new DapiDB(ipfs, dbPath)
let store = dapidb.create(name, CustomStore.type)

Development

Run Tests

npm test

Build

npm run build

Benchmark

node benchmarks/benchmark-add.js

See benchmarks/ for more benchmarks.

Logging

To enable DapiDB's logging output, set a global ENV variable called LOG to debug,warn or error:

LOG=debug node <file>

Background

Uses the following modules:

To understand a little bit about the architecture, check out a visualization of the data flow at https://github.com/haadcode/proto2 or a live demo: http://celebdil.benet.ai:8080/ipfs/Qmezm7g8mBpWyuPk6D84CNcfLKJwU6mpXuEN5GJZNkX3XK/.

License

MIT ©️ 2017 Haadcode