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

liber

v0.0.4

Published

Shemaless ORMlike library for CouchDB

Downloads

7

Readme

liber

Liber makes using CouchDB not only easier to build but also shemaless. It is built on nano and inspired by AngularJS-Resource. Principles:

  • Minimalistic: Keep functions you would be using(view generation etc.) once out of this one. CouchDB's api is simple - do them using nano.
  • Shemaless: NoSQL is shemaless why should a driver differ.
  • Expectedness: Don't try to squeeze features of a RDBMS out of CouchDB, ergo don't generate anything automatically in the background. Be in control and know whats happening.

Installation

Liber is nothing but a extended api for nano so for using it you also need the latter - it's good to have anyways working with CouchDB:

npm install liber nano

Getting started

to set liber up

var nano = require('nano')('http://localhost:5984/mydatabase');
var Liber = require('liber')(db); //alias for document

now... live a simpler life

Liber.getOne('bobs_id', function (err, bob) {
  bob.age++;
  bob.save(function (err, newBob) {
    //newBob == bob;
  });
});

##Inheritance

function User(data) {
  this.superClass.call(this, data); // to give more flexibility
                                    // to construction process
  this.kind = 'user';
  this.fullName = this.lastName + ', ' + this.firstName;
}

User = Liber.inherit(User, {
  changePassword: function () { ... }
}, {
  'viewShortcuts': {
    'byLastName': ['myDesignDoc', 'usersByLastName']
  }
});

User.get('anId', cb);
/*
  get by id
  Note: Liber doesn't validate the kind or type so you could
  fetch an User from any other Liber class.
*/

User.getByLastName('Smith', cb);
// get user from an generated view getter. Result is an array.

User.getOneByLastName('Smith', cb);
// same as the last one but result is User object.

##API: Class methods

###Liber.inherit(constructor, prototype, options) ###Liber.parse(data) ###Liber.get(params, callback) ###Liber.getOne(id, [params, callback]) ###Liber.getFromView(design, view, params, callback) ###Liber.getOneFromView(design, view, params, callback)

##API: Instance methods

###Doc.save(callback) ###Doc.insert(callback) ###Doc.destroy(callback)

##API: Options

###View shortcuts: viewShortcuts Generates methods to access views. Needs array of parameters to concat to the beginning of parameters of method calls. Let's say User class declaration has a options of:

{
  'viewShortcuts': {
    'fromMyDesign': ['myDesignDoc'],
    'byLastName': ['myDesignDoc', 'usersByLastName'],
    'admins': ['myDesignDoc', 'usersByStatus', 'admin']
  }
}

then

User.getOneFromMyDesign('usersByAddress', 'broad way');
// == User.getOneFromView('myDesignDoc', 'usersByAddress', 'broad way');

User.getByLastName('smith');
// == User.getFromView('myDesignDoc', 'usersByLastName', 'smith');

User.getAdmins();
// == User.getFromView('myDesignDoc', 'usersByStatus', 'admin');

Although linguistically a bit off, the getOneAdmins would limit latter to first match. The shortcuts are very cheap to make so you could fix that by duplicating 'admins' with an 'admin' so you'll have both get(One)Admin and get(One)Admins.