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

qcouch

v0.0.3

Published

A wrapper for felix-couchdb which uses promises instead of callbacks, and adds a number of helper behaviours.

Downloads

4

Readme

The basic premise of QCouch is felix-couchdb + Q, and the most basic use case is:

db = new qcouch({ databasename:"mydb" });
db.getDoc("mydocid").then(function(doc){
  // your stuff here
});

This makes it easier to work with parrallel and sequential couchdb requests without needing crazy callbacks.

But since I was writing a wrapper, I decided to add some other functionality I find useful.

Database Intialization

If database doesn't exist, qcouch will automatically attempt to create it.

Design Intialization and Updating

If the specified designs don't exist, qcouch will automatically add them; if they do exist but are different, qcouch will update them.

View Helpers

runView, which generally an alias to view, also has some added functionality.

Just the Keys

Add resolveto:"keys" to the query. When you do that it will return a simple array of keys instead of the standard couchdb result.

Just the Docs

You can also add resolveto:"keys" to the query to get a simple array of objects.

Pagination

If you add resolveto and limit, you get some pagination help. The returned array will be limit - 1 long (i.e. you should set limit to pagesize + 1), and will have hidden pagination properties: startkey, startkey_docid, next_startkey, and next_startkey_docid. The next values are only set if there are more pages.

db.runView("somedesign","someview",{ resolveto:"objects", limit:6 });
// returns an array of 5 objects, with next_startkey and next_startkey_docid

allDocs

If you want to use these behaviours for the allDocs function:

db.runView("allDocs",{ resolveto:"objects", limit:6 });

Pre-save and Post-get functions

db = new qcouch({
  databasename : "mydb",
  fromDB : function(doc){ return replacement_doc; },
  toDB : function(doc){ return replacement_doc; }
})

These are helpful when you want a central function that modifies documents before they are saved (e.g. to convert your own weird classes into objects), or after they are retrieved but before your application starts using them (e.g. to add functions or dynamically generated values).

fromDB and toDB are applied in getDoc, runView where resolveto is "objects" (including "allDocs"), saveDoc, and bulkDocs.