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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@korbiniankuhn/pouchoose

v0.0.3

Published

Mongoose for pouchdb

Readme

Pouchoose - Mongoose for PouchDB

Heavily work in progress!

Mongoose-like API for PouchDB.

  • Schema definition (Validation, Hooks, Indexing)
  • Powerful queries based on PouchDB-Find
  • Populate schema references
  • Optional encryption

See full documentation here

Connection

import { connect } from 'pouchoose';

// Easily connect to a database
const connection = await connect('database-name');

// Count all documents
const count = await connection.countAllDocuments();

// Remove all documents
await connection.removeAllDocuments();

// Disconnect from the database
await connection.disconnect();

Schema

import { model, Schema } from 'pouchoose';

// TS-Interface is optional
interface IPerson {
  name: string;
  age: number;
}

// Define a Schema
const PersonSchema = new Schema({
  name: String,
  age: {
    type: Number,
    default: 42,
  },
});

// Create a Model (TS-Interface is optional)
const Person = model<IPerson>('Person', PersonSchema);

Queries

// Create person instantly
const jane = await Person.create({ name: 'Jane Doe' });

// Create person and save later
const john = Person.new({ name: 'John Doe' });
await john.save();

// Find persons
const persons = await Person.find();

Methods

  • new Model(doc)
  • count(conditions)
  • create(doc)
  • exists(conditions)
  • find(conditions)
  • findAndDelete(conditions)
  • findAndUpdate(conditions, update)
  • findById(id)
  • findByIdAndDelete(id)
  • findByIdAndUpdate(id, update)
  • findOne(conditions)
  • findOneAndDelete(conditions)
  • findOneAndUpdate(conditions, update)
  • insertMany(docs)

Populate

const userSchema = new Schema({
  name: String,
  comments: [
    {
      type: String,
      ref: 'Comment',
    },
  ],
});
const User = model('User', userSchema);

const commentSchema = new Schema({
  message: String,
  user: {
    type: String,
    ref: 'User',
  },
});
const User = model('User', userSchema);

const userWithComments = await User.findOne({ name: 'Jane Doe' }).populate(
  'comments'
);

Hooks

Not implemented

Changes

Subscribe to changes on connection-, model- or document-level.

import { Subscription } from 'rxjs';

const subscriptions = new Subscription();

// Subscribe to all doc changes. Docs are lean json-objects.
subscriptions.add(
  connection.watch().subscribe((e: GenericDocumentStream) => {
    console.log(e);
    // { change: 'add' | 'update' | 'delete', doc: any }
  })
);

// Subscribe to Person doc changes and filter only delete events. Docs are Document-Classes.
subscriptions.add(
  Person.watch()
    .filter((e: DocumentStream) => e.change === 'delete')
    .subscribe((e) => {
      console.log(e);
      // { change: 'add' | 'update' | 'delete', doc: IPerson }
    })
);

// Subscribe to all changes of a specific document
const jane = await Person.find({ name: 'Jane Doe' });
subscriptions.add(
  Person.watch().subscribe((e: DocumentStream) => {
    console.log(e);
    // { change: 'add' | 'update' | 'delete', doc: IPerson }
  })
);

// Don't forget to unsubscribe
subscriptions.unsubscribe();

Encryption

Use callbacks to enable encryption with your custom logic and encryption library of choice (e.g. node-forge). These callbacks are executed on every CRUD-Operation, e.g. on a read-query before schema validation or on a write-query after schema validation.

import { GenericDoc } from 'pouchoose';

connection.encrypt = async (docs: GenericDoc[]): Promise<GenericDoc[]> => {
  return docs.map((doc) => {
    const encrypted: GenericDoc = {};
    const content: { [key: string]: any } = {};

    // Skip some keys for encryption
    for (const key of Object.keys(doc)) {
      if (key.startsWith('$') || key.startsWith('_')) {
        encrypted[key] = doc[key];
      } else {
        content[key] = doc[key];
      }
    }

    // Encrypt content
    encrypted.$crypto = {
      alg: 'stringify',
      content: JSON.stringify(content),
    };

    return encrypted;
  });
};

connection.decrypt = async (docs: GenericDoc[]): Promise<GenericDoc[]> => {
  return docs.map((doc) => {
    const { $crypto, ...decrypted } = doc;

    // Eventually decrypt content
    if ($crypto) {
      Object.assign(decrypted, JSON.parse($crypto.content));
    }

    return decrypted;
  });
};