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

@carbon-io/leafnode

v0.5.2

Published

Sync driver for MongoDB

Downloads

117

Readme

leafnode

Build Status

leafnode is a "synchronous" MongoDB driver. It is a wrapper around node-mongodb-native implemented using the node-fibers co-routine library.

leafnode is currently experimental and in alpha.

Example:

var connect = require('@carbon-io/leafnode').connect;

try {
   var db = connect("mongodb://localhost:27017/mydb");
   var c = db.getCollection("users");
   var results = c.find({"firstName" : "Joe"}).toArray();
   console.log(results);
} catch e {
   console.log(e);
}

No callbacks needed. If an error occurs an exception is thrown.

We say "synchronous" because leafnode code execution is still asynchronous under the hood, but uses Fibers to provide a synchronous programming interface. One should therefore note that many functions and methods of this driver actually yield control to the event loop during execution. For more on Fibers see the documenentation here.

Installation

Using npm

% cd <your-app>
% npm install leafnode

From git

% git clone [email protected]:objectlabs/leafnode.git
% cd <your-app>
% npm install <path-to-leafnode>

To run unit tests

% node ./test/all.js

Using leafnode in your code

In order to use leafnode you need to properly bootstrap your application by creating a Fiber for the code to run in.

The basic idea is as follows:

require('fibers');

Fiber(function() {
  //do stuff
}).run();

In practice you will want to do this at the beginning of a command line program or, if using an application toolkit like express, as you process each request. One nice way of achieving this in express is to add a middleware function that wraps request handling in a Fiber.

app.use(function(req, res, next) {
   Fiber(function() {
      next();
   }).run();
});

Open issues

  • Support for options in MongoDB URI uneven