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

minip

v1.0.1

Published

Mini P is a simple database that can replicate with CouchDB.

Downloads

7

Readme

Mini P

Mini P (Berlin slang for mini pizza) is a simple database that can replicate with CouchDB.

This is an experimental project. If you're looking for something to use in production, consider PouchDB.

Build Status

Adapters

Mini P provides two adapters by now:

  • MemoryP - in memory store
  • HttpP - talks to a real CouchDB

both share the same interface.

API

The API is just two methods:

  • read(options)
  • write(docs, options)

(and a reset used for testing)

Options

  • For read you pass { revs: true } and get _revisions included in the documents
  • For write you can pass { new_edits: false } to circumvent optimistic locking

Pull Streams

You can create pull-streams out of an adapter by calling stream.reader(db) or stream.writer(db).

Replication

For replication you just pipe a reader stream into a writer stream:

pull(
  stream.reader(source)({ revs: true }),
  stream.writer(target)({ new_edits: false })
)

The CouchDB replication protocol replicates documents via the changes feed. This replication, though, is based on allDocs by now.

Dependencies

Mini P requires Node v8.
HttpP adapter only works with CouchDB 2 (relies on _bulk_get).
The only npm dependency is request, which is used for the HttpP adapter.

Example

import { HttpP, MemoryP, stream } from 'minip'
import pull from 'pull-stream'
import onEnd from 'pull-stream/sinks/on-end'

const local = new MemoryP()
const remote = new HttpP('http://localhost:5984/mydb')

// write to local database
local.write([{ _id: 'foo', bar: 'baz' }], (error, response) => {
  // replicate local to remote
  pull(
    stream.reader(source)({ revs: true }),
    stream.writer(target)({ new_edits: false }),
    onEnd(() => {
      // once finished, query remote db
      remote.read((error, [doc]) => {
        // {
        //   _id: 'foo',
        //   _rev: '1-b3cec23b98d5f20d20a8279878ddce3d',
        //   bar: 'baz'
        // }
      })
    })
  )
})

State of Mini P

What Works

  • Store and retrieve a bunch of docs
  • Store docs with new_edits: false.
  • Get docs with revs: true
  • Update a doc, increment _rev
  • choose winning rev
  • replicating a whole database
  • merge _revisions tree on new_edits:false

What does not work

Everything else.

No changes feed. No views. Almost no error handling. No deletes. No checkpointing. No revs diff. Hah: no attachments for sure.

Development

The development process is pretty straight forward:

  • Write a test and works with HttpP break MemoryP
  • Fix MemoryP

Tests

Additionaly to npm test a npm run test:perf task provides you with some numbers for throughput.

All tests run against all adapters. Replication is tested across all adapter combinations.

(c) 2018 J. J. Schmidt