Code Monkey home page Code Monkey logo

hyperdb-questions's Introduction

hyperdb-questions

Sample repo connecting the hyperdb to a discovery-swarm for the purpose of asking a few questions.
Derived from @cblgh's super helpful example.


Also, HUGE gratitude and thanks to @mafintosh (and everyone else contributing) for creating these building blocks. What a treasure trove of extraordinary work.

Questions

I have a few orienting questions as I start getting my hands dirty with some code.
I've posted each question as an issue to allow easy comments and discussion there for anyone who can weigh in (thanks!).

Example Code

npm install # yada yada yada

Open 1..n consoles running:

npm start

Each console creates a new hyperdb, using the initial database's dbKey.

The demo simply writes arbitray values to the primary database on a loop (db-1). Subsequence windows (db-2...etc) listen and log the changes.

demo

To delete the databases and start again:

npm run reset

Refs

hyperdb-questions's People

Contributors

philcockfield avatar

Watchers

 avatar James Cloos avatar  avatar

hyperdb-questions's Issues

Question: Map and Reduce usage in HyperDB options

When are are the map and reduce options that are passed into the hyperdb construcgtor invoked, and how should they be used/implemented by the consuming app?

const hyperdb = require('hyperdb');

/**
 * Construct a new instance of a [hyperdb].
 * See:
 * - https://github.com/mafintosh/hyperdb
 */
function create(args = {}) {
  const reduce = (a, b) => a;
  const map = node => node;
  return new Promise(resolve => {
    const { dir, dbKey } = args;
    const options = { valueEncoding: 'utf-8', reduce, map };
    const db = dbKey ? hyperdb(dir, dbKey, options) : hyperdb(dir, options);
    db.on('ready', () => resolve(db));
  });
}

refs:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.